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

Unified Diff: net/dns/mdns_query.cc

Issue 15733008: Multicast DNS implementation (initial) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mdns_implementation2
Patch Set: 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: net/dns/mdns_query.cc
diff --git a/net/dns/mdns_query.cc b/net/dns/mdns_query.cc
new file mode 100644
index 0000000000000000000000000000000000000000..80a6c23fe7b44116878bd7da2fd3adac1110b58f
--- /dev/null
+++ b/net/dns/mdns_query.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 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.
+
+#include "net/dns/mdns_query.h"
+
+#include "base/sys_byteorder.h"
+#include "net/base/big_endian.h"
+#include "net/base/dns_util.h"
+#include "net/dns/dns_protocol.h"
+
+namespace net {
+
+MDnsQuery::MDnsQuery(const base::StringPiece& qname, uint16 qtype) {
+ DCHECK(!DNSDomainToString(qname).empty());
+
+ // QNAME + QTYPE + QCLASS
+ size_t question_size = qname.size() + sizeof(uint16) + sizeof(uint16);
+ io_buffer_ = new IOBufferWithSize(sizeof(dns_protocol::Header) +
+ question_size);
+ dns_protocol::Header* header =
+ reinterpret_cast<dns_protocol::Header*>(io_buffer_->data());
+ memset(header, 0, sizeof(dns_protocol::Header));
+ // Do not set ID or flags.
+ header->qdcount = base::HostToNet16(1);
+
+ // Write question section after the header.
+ BigEndianWriter writer(reinterpret_cast<char*>(header + 1), question_size);
+ writer.WriteBytes(qname.data(), qname.size());
+ writer.WriteU16(qtype);
+ writer.WriteU16(dns_protocol::kClassIN);
+}
+
+MDnsQuery::~MDnsQuery() {
+}
+}
« net/dns/mdns_query.h ('K') | « net/dns/mdns_query.h ('k') | net/dns/mdns_query_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698