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

Unified Diff: cloud_print/gcp20/prototype/dns_packet_parser.cc

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: Fixed Lint error. 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_packet_parser.cc
diff --git a/cloud_print/gcp20/prototype/dns_packet_parser.cc b/cloud_print/gcp20/prototype/dns_packet_parser.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8dd3ad690b8522703a5b70f12341fcdd433427b4
--- /dev/null
+++ b/cloud_print/gcp20/prototype/dns_packet_parser.cc
@@ -0,0 +1,38 @@
+// 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.
+
+#include "cloud_print/gcp20/prototype/dns_packet_parser.h"
+
+#include "net/base/big_endian.h"
+
+DnsQueryRecord::DnsQueryRecord() {
+}
+
+DnsQueryRecord::~DnsQueryRecord() {
+}
+
+DnsPacketParser::DnsPacketParser() : packet_(NULL), length_(0) {
+}
+
+DnsPacketParser::DnsPacketParser(const char* packet,
+ size_t length,
+ size_t offset)
+ : packet_(packet),
+ length_(length),
+ record_parser_(packet, length, offset) {
+}
+
+bool DnsPacketParser::ReadRecord(DnsQueryRecord* out) {
+ DCHECK(packet_);
+ size_t consumed = ReadName(&out->qname);
+ if (!consumed)
+ return false;
+ net::BigEndianReader reader(packet_ + GetOffset() + consumed,
+ length_ - (GetOffset() + consumed));
+ if (reader.ReadU16(&out->qtype) && reader.ReadU16(&out->qclass))
+ return record_parser_.SkipQuestion(); // instead of |cur_ = reader.ptr();|
+
+ return false;
+}
+

Powered by Google App Engine
This is Rietveld 408576698