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

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

Issue 16389002: GCP2.0 Device: mDNS basics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected "Binds". 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_sd.h
diff --git a/cloud_print/gcp20/prototype/dns_sd.h b/cloud_print/gcp20/prototype/dns_sd.h
new file mode 100644
index 0000000000000000000000000000000000000000..9d007d4d0225325c01ca95df9ab1fa8e2e7a0575
--- /dev/null
+++ b/cloud_print/gcp20/prototype/dns_sd.h
@@ -0,0 +1,81 @@
+// 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 GCP20_PROTOTYPE_DNS_SD_H_
+#define GCP20_PROTOTYPE_DNS_SD_H_
+
+#include <vector>
+
+#include "net/udp/udp_socket.h"
+
+// Class for sending multicast announcements, receiving queries and answering on
+// them. Client should call |ProccessMessages| periodically to make server work.
gene 2013/06/06 00:13:51 Add a ProcessMessage() function, make it NOTIMPLEM
maksymb 2013/06/06 01:52:46 Done.
+class DnsSd {
+ public:
+ // Constructs unstarted server.
+ DnsSd();
+
+ // Stops server.
+ ~DnsSd();
+
+ // Starts the server. Returns |true| if server works. Also sends
+ // announcement.
+ bool Start();
+
+ // Sends announcement if server works.
+ void Update();
+
+ // Stops server with announcement.
+ void Shutdown();
+
+ // Returns |true| if server works.
+ bool is_online() { return is_online_; }
+
+ private:
+ // Binds a socket to multicast address. Returns |true| on success.
+ bool BindSocket();
+
+ // Sends announcement.
+ void SendAnnouncement(uint32 ttl);
+
+ // Returns |true| if server received some questions.
+ bool CheckPendingQueries();
+
+ // Sets the header of DNS packet after adding all of necessary queries and
+ // answers.
+ void UpdateHeader(bool is_question, std::vector<uint8>* message);
+
+ // Appends answer on SRV query at the end of |message|.
+ void AppendSrv(uint32 ttl, std::vector<uint8>* message);
+
+ // Appends answer on PTR query at the end of |message|.
+ void AppendPtr(uint32 ttl, std::vector<uint8>* message);
+
+ // Appends answer on TXT query at the end of |message|.
+ void AppendTxt(uint32 ttl, std::vector<uint8>* message);
+
+ // Appends answer on A query at the end of |message|.
+ void AppendA(uint32 ttl, std::vector<uint8>* message);
+
+
+ // Stores |true| if server was started.
+ bool is_online_;
+
+ // Stores socket to multicast address.
+ scoped_ptr<net::UDPSocket> socket_;
+
+ // Stores multicast address end point.
+ net::IPEndPoint multicast_address_;
+
+
+ // Stores number of question in current DNS packet.
+ uint16 question_count_;
+
+ // Stores number of answers in current DNS packet.
+ uint16 answers_count_;
+};
gene 2013/06/06 00:13:51 add chrome macro to disable copy contructor
maksymb 2013/06/06 01:52:46 Do you mean DISALLOW_COPY_AND_ASSIGN? Then done.
+
+
+#endif // GCP20_PROTOTYPE_DNS_SD_H_
+

Powered by Google App Engine
This is Rietveld 408576698