Improve the documentation of MdnsResponderInterface and rename MDns.*
to Mdns.*. MdnsResponderInterface now explicitly requires the reference counting of created names to allow the coexistence of multiple users of the same responder where one user would not remove identical names created by others. MDns.* is also renamed to Mdns.* per the style guide. TBR=aleloi@webrtc.org Bug: webrtc:9605 Change-Id: I047fc41f34de8d4e97c980409a7f373769c4c252 Reviewed-on: https://webrtc-review.googlesource.com/c/101921 Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Reviewed-by: Qingsi Wang <qingsi@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25458}
This commit is contained in:
parent
eb2c6415a9
commit
7852d291c9
@ -19,13 +19,13 @@ namespace {
|
|||||||
// RFC 1035, Section 4.1.1.
|
// RFC 1035, Section 4.1.1.
|
||||||
//
|
//
|
||||||
// QR bit.
|
// QR bit.
|
||||||
constexpr uint16_t kMDnsFlagMaskQueryOrResponse = 0x8000;
|
constexpr uint16_t kMdnsFlagMaskQueryOrResponse = 0x8000;
|
||||||
// AA bit.
|
// AA bit.
|
||||||
constexpr uint16_t kMDnsFlagMaskAuthoritative = 0x0400;
|
constexpr uint16_t kMdnsFlagMaskAuthoritative = 0x0400;
|
||||||
// RFC 1035, Section 4.1.2, QCLASS and RFC 6762, Section 18.12, repurposing of
|
// RFC 1035, Section 4.1.2, QCLASS and RFC 6762, Section 18.12, repurposing of
|
||||||
// top bit of QCLASS as the unicast response bit.
|
// top bit of QCLASS as the unicast response bit.
|
||||||
constexpr uint16_t kMDnsQClassMaskUnicastResponse = 0x8000;
|
constexpr uint16_t kMdnsQClassMaskUnicastResponse = 0x8000;
|
||||||
constexpr size_t kMDnsHeaderSizeBytes = 12;
|
constexpr size_t kMdnsHeaderSizeBytes = 12;
|
||||||
|
|
||||||
bool ReadDomainName(MessageBufferReader* buf, std::string* name) {
|
bool ReadDomainName(MessageBufferReader* buf, std::string* name) {
|
||||||
size_t name_start_pos = buf->CurrentOffset();
|
size_t name_start_pos = buf->CurrentOffset();
|
||||||
@ -64,7 +64,7 @@ bool ReadDomainName(MessageBufferReader* buf, std::string* name) {
|
|||||||
// A legitimate pointer only refers to a prior occurrence of the same name,
|
// A legitimate pointer only refers to a prior occurrence of the same name,
|
||||||
// and we should only move strictly backward to a prior name field after the
|
// and we should only move strictly backward to a prior name field after the
|
||||||
// header.
|
// header.
|
||||||
if (pos_jump_to >= name_start_pos || pos_jump_to < kMDnsHeaderSizeBytes) {
|
if (pos_jump_to >= name_start_pos || pos_jump_to < kMdnsHeaderSizeBytes) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MessageBufferReader new_buf(buf->MessageData(), buf->MessageLength());
|
MessageBufferReader new_buf(buf->MessageData(), buf->MessageLength());
|
||||||
@ -88,27 +88,27 @@ void WriteDomainName(rtc::ByteBufferWriter* buf, const std::string& name) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void MDnsHeader::SetQueryOrResponse(bool is_query) {
|
void MdnsHeader::SetQueryOrResponse(bool is_query) {
|
||||||
if (is_query) {
|
if (is_query) {
|
||||||
flags &= ~kMDnsFlagMaskQueryOrResponse;
|
flags &= ~kMdnsFlagMaskQueryOrResponse;
|
||||||
} else {
|
} else {
|
||||||
flags |= kMDnsFlagMaskQueryOrResponse;
|
flags |= kMdnsFlagMaskQueryOrResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsHeader::SetAuthoritative(bool is_authoritative) {
|
void MdnsHeader::SetAuthoritative(bool is_authoritative) {
|
||||||
if (is_authoritative) {
|
if (is_authoritative) {
|
||||||
flags |= kMDnsFlagMaskAuthoritative;
|
flags |= kMdnsFlagMaskAuthoritative;
|
||||||
} else {
|
} else {
|
||||||
flags &= ~kMDnsFlagMaskAuthoritative;
|
flags &= ~kMdnsFlagMaskAuthoritative;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsHeader::IsAuthoritative() const {
|
bool MdnsHeader::IsAuthoritative() const {
|
||||||
return flags & kMDnsFlagMaskAuthoritative;
|
return flags & kMdnsFlagMaskAuthoritative;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsHeader::Read(MessageBufferReader* buf) {
|
bool MdnsHeader::Read(MessageBufferReader* buf) {
|
||||||
if (!buf->ReadUInt16(&id) || !buf->ReadUInt16(&flags) ||
|
if (!buf->ReadUInt16(&id) || !buf->ReadUInt16(&flags) ||
|
||||||
!buf->ReadUInt16(&qdcount) || !buf->ReadUInt16(&ancount) ||
|
!buf->ReadUInt16(&qdcount) || !buf->ReadUInt16(&ancount) ||
|
||||||
!buf->ReadUInt16(&nscount) || !buf->ReadUInt16(&arcount)) {
|
!buf->ReadUInt16(&nscount) || !buf->ReadUInt16(&arcount)) {
|
||||||
@ -118,7 +118,7 @@ bool MDnsHeader::Read(MessageBufferReader* buf) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsHeader::Write(rtc::ByteBufferWriter* buf) const {
|
void MdnsHeader::Write(rtc::ByteBufferWriter* buf) const {
|
||||||
buf->WriteUInt16(id);
|
buf->WriteUInt16(id);
|
||||||
buf->WriteUInt16(flags);
|
buf->WriteUInt16(flags);
|
||||||
buf->WriteUInt16(qdcount);
|
buf->WriteUInt16(qdcount);
|
||||||
@ -127,15 +127,15 @@ void MDnsHeader::Write(rtc::ByteBufferWriter* buf) const {
|
|||||||
buf->WriteUInt16(arcount);
|
buf->WriteUInt16(arcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsHeader::IsQuery() const {
|
bool MdnsHeader::IsQuery() const {
|
||||||
return !(flags & kMDnsFlagMaskQueryOrResponse);
|
return !(flags & kMdnsFlagMaskQueryOrResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
MDnsSectionEntry::MDnsSectionEntry() = default;
|
MdnsSectionEntry::MdnsSectionEntry() = default;
|
||||||
MDnsSectionEntry::~MDnsSectionEntry() = default;
|
MdnsSectionEntry::~MdnsSectionEntry() = default;
|
||||||
MDnsSectionEntry::MDnsSectionEntry(const MDnsSectionEntry& other) = default;
|
MdnsSectionEntry::MdnsSectionEntry(const MdnsSectionEntry& other) = default;
|
||||||
|
|
||||||
void MDnsSectionEntry::SetType(SectionEntryType type) {
|
void MdnsSectionEntry::SetType(SectionEntryType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SectionEntryType::kA:
|
case SectionEntryType::kA:
|
||||||
type_ = 1;
|
type_ = 1;
|
||||||
@ -148,7 +148,7 @@ void MDnsSectionEntry::SetType(SectionEntryType type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionEntryType MDnsSectionEntry::GetType() const {
|
SectionEntryType MdnsSectionEntry::GetType() const {
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case 1:
|
case 1:
|
||||||
return SectionEntryType::kA;
|
return SectionEntryType::kA;
|
||||||
@ -159,7 +159,7 @@ SectionEntryType MDnsSectionEntry::GetType() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsSectionEntry::SetClass(SectionEntryClass cls) {
|
void MdnsSectionEntry::SetClass(SectionEntryClass cls) {
|
||||||
switch (cls) {
|
switch (cls) {
|
||||||
case SectionEntryClass::kIN:
|
case SectionEntryClass::kIN:
|
||||||
class_ = 1;
|
class_ = 1;
|
||||||
@ -169,7 +169,7 @@ void MDnsSectionEntry::SetClass(SectionEntryClass cls) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionEntryClass MDnsSectionEntry::GetClass() const {
|
SectionEntryClass MdnsSectionEntry::GetClass() const {
|
||||||
switch (class_) {
|
switch (class_) {
|
||||||
case 1:
|
case 1:
|
||||||
return SectionEntryClass::kIN;
|
return SectionEntryClass::kIN;
|
||||||
@ -178,11 +178,11 @@ SectionEntryClass MDnsSectionEntry::GetClass() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MDnsQuestion::MDnsQuestion() = default;
|
MdnsQuestion::MdnsQuestion() = default;
|
||||||
MDnsQuestion::MDnsQuestion(const MDnsQuestion& other) = default;
|
MdnsQuestion::MdnsQuestion(const MdnsQuestion& other) = default;
|
||||||
MDnsQuestion::~MDnsQuestion() = default;
|
MdnsQuestion::~MdnsQuestion() = default;
|
||||||
|
|
||||||
bool MDnsQuestion::Read(MessageBufferReader* buf) {
|
bool MdnsQuestion::Read(MessageBufferReader* buf) {
|
||||||
if (!ReadDomainName(buf, &name_)) {
|
if (!ReadDomainName(buf, &name_)) {
|
||||||
RTC_LOG(LS_ERROR) << "Invalid name.";
|
RTC_LOG(LS_ERROR) << "Invalid name.";
|
||||||
return false;
|
return false;
|
||||||
@ -194,31 +194,31 @@ bool MDnsQuestion::Read(MessageBufferReader* buf) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsQuestion::Write(rtc::ByteBufferWriter* buf) const {
|
bool MdnsQuestion::Write(rtc::ByteBufferWriter* buf) const {
|
||||||
WriteDomainName(buf, name_);
|
WriteDomainName(buf, name_);
|
||||||
buf->WriteUInt16(type_);
|
buf->WriteUInt16(type_);
|
||||||
buf->WriteUInt16(class_);
|
buf->WriteUInt16(class_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsQuestion::SetUnicastResponse(bool should_unicast) {
|
void MdnsQuestion::SetUnicastResponse(bool should_unicast) {
|
||||||
if (should_unicast) {
|
if (should_unicast) {
|
||||||
class_ |= kMDnsQClassMaskUnicastResponse;
|
class_ |= kMdnsQClassMaskUnicastResponse;
|
||||||
} else {
|
} else {
|
||||||
class_ &= ~kMDnsQClassMaskUnicastResponse;
|
class_ &= ~kMdnsQClassMaskUnicastResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsQuestion::ShouldUnicastResponse() const {
|
bool MdnsQuestion::ShouldUnicastResponse() const {
|
||||||
return class_ & kMDnsQClassMaskUnicastResponse;
|
return class_ & kMdnsQClassMaskUnicastResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
MDnsResourceRecord::MDnsResourceRecord() = default;
|
MdnsResourceRecord::MdnsResourceRecord() = default;
|
||||||
MDnsResourceRecord::MDnsResourceRecord(const MDnsResourceRecord& other) =
|
MdnsResourceRecord::MdnsResourceRecord(const MdnsResourceRecord& other) =
|
||||||
default;
|
default;
|
||||||
MDnsResourceRecord::~MDnsResourceRecord() = default;
|
MdnsResourceRecord::~MdnsResourceRecord() = default;
|
||||||
|
|
||||||
bool MDnsResourceRecord::Read(MessageBufferReader* buf) {
|
bool MdnsResourceRecord::Read(MessageBufferReader* buf) {
|
||||||
if (!ReadDomainName(buf, &name_)) {
|
if (!ReadDomainName(buf, &name_)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -239,17 +239,17 @@ bool MDnsResourceRecord::Read(MessageBufferReader* buf) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool MDnsResourceRecord::ReadARData(MessageBufferReader* buf) {
|
bool MdnsResourceRecord::ReadARData(MessageBufferReader* buf) {
|
||||||
// A RDATA contains a 32-bit IPv4 address.
|
// A RDATA contains a 32-bit IPv4 address.
|
||||||
return buf->ReadString(&rdata_, 4);
|
return buf->ReadString(&rdata_, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsResourceRecord::ReadQuadARData(MessageBufferReader* buf) {
|
bool MdnsResourceRecord::ReadQuadARData(MessageBufferReader* buf) {
|
||||||
// AAAA RDATA contains a 128-bit IPv6 address.
|
// AAAA RDATA contains a 128-bit IPv6 address.
|
||||||
return buf->ReadString(&rdata_, 16);
|
return buf->ReadString(&rdata_, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsResourceRecord::Write(rtc::ByteBufferWriter* buf) const {
|
bool MdnsResourceRecord::Write(rtc::ByteBufferWriter* buf) const {
|
||||||
WriteDomainName(buf, name_);
|
WriteDomainName(buf, name_);
|
||||||
buf->WriteUInt16(type_);
|
buf->WriteUInt16(type_);
|
||||||
buf->WriteUInt16(class_);
|
buf->WriteUInt16(class_);
|
||||||
@ -270,15 +270,15 @@ bool MDnsResourceRecord::Write(rtc::ByteBufferWriter* buf) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsResourceRecord::WriteARData(rtc::ByteBufferWriter* buf) const {
|
void MdnsResourceRecord::WriteARData(rtc::ByteBufferWriter* buf) const {
|
||||||
buf->WriteString(rdata_);
|
buf->WriteString(rdata_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsResourceRecord::WriteQuadARData(rtc::ByteBufferWriter* buf) const {
|
void MdnsResourceRecord::WriteQuadARData(rtc::ByteBufferWriter* buf) const {
|
||||||
buf->WriteString(rdata_);
|
buf->WriteString(rdata_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsResourceRecord::SetIPAddressInRecordData(
|
bool MdnsResourceRecord::SetIPAddressInRecordData(
|
||||||
const rtc::IPAddress& address) {
|
const rtc::IPAddress& address) {
|
||||||
int af = address.family();
|
int af = address.family();
|
||||||
if (af != AF_INET && af != AF_INET6) {
|
if (af != AF_INET && af != AF_INET6) {
|
||||||
@ -293,7 +293,7 @@ bool MDnsResourceRecord::SetIPAddressInRecordData(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsResourceRecord::GetIPAddressFromRecordData(
|
bool MdnsResourceRecord::GetIPAddressFromRecordData(
|
||||||
rtc::IPAddress* address) const {
|
rtc::IPAddress* address) const {
|
||||||
if (GetType() != SectionEntryType::kA &&
|
if (GetType() != SectionEntryType::kA &&
|
||||||
GetType() != SectionEntryType::kAAAA) {
|
GetType() != SectionEntryType::kAAAA) {
|
||||||
@ -310,16 +310,16 @@ bool MDnsResourceRecord::GetIPAddressFromRecordData(
|
|||||||
return rtc::IPFromString(std::string(out), address);
|
return rtc::IPFromString(std::string(out), address);
|
||||||
}
|
}
|
||||||
|
|
||||||
MDnsMessage::MDnsMessage() = default;
|
MdnsMessage::MdnsMessage() = default;
|
||||||
MDnsMessage::~MDnsMessage() = default;
|
MdnsMessage::~MdnsMessage() = default;
|
||||||
|
|
||||||
bool MDnsMessage::Read(MessageBufferReader* buf) {
|
bool MdnsMessage::Read(MessageBufferReader* buf) {
|
||||||
RTC_DCHECK_EQ(0u, buf->CurrentOffset());
|
RTC_DCHECK_EQ(0u, buf->CurrentOffset());
|
||||||
if (!header_.Read(buf)) {
|
if (!header_.Read(buf)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto read_question = [&buf](std::vector<MDnsQuestion>* section,
|
auto read_question = [&buf](std::vector<MdnsQuestion>* section,
|
||||||
uint16_t count) {
|
uint16_t count) {
|
||||||
section->resize(count);
|
section->resize(count);
|
||||||
for (auto& question : (*section)) {
|
for (auto& question : (*section)) {
|
||||||
@ -329,7 +329,7 @@ bool MDnsMessage::Read(MessageBufferReader* buf) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
auto read_rr = [&buf](std::vector<MDnsResourceRecord>* section,
|
auto read_rr = [&buf](std::vector<MdnsResourceRecord>* section,
|
||||||
uint16_t count) {
|
uint16_t count) {
|
||||||
section->resize(count);
|
section->resize(count);
|
||||||
for (auto& rr : (*section)) {
|
for (auto& rr : (*section)) {
|
||||||
@ -349,10 +349,10 @@ bool MDnsMessage::Read(MessageBufferReader* buf) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsMessage::Write(rtc::ByteBufferWriter* buf) const {
|
bool MdnsMessage::Write(rtc::ByteBufferWriter* buf) const {
|
||||||
header_.Write(buf);
|
header_.Write(buf);
|
||||||
|
|
||||||
auto write_rr = [&buf](const std::vector<MDnsResourceRecord>& section) {
|
auto write_rr = [&buf](const std::vector<MdnsResourceRecord>& section) {
|
||||||
for (auto rr : section) {
|
for (auto rr : section) {
|
||||||
if (!rr.Write(buf)) {
|
if (!rr.Write(buf)) {
|
||||||
return false;
|
return false;
|
||||||
@ -374,7 +374,7 @@ bool MDnsMessage::Write(rtc::ByteBufferWriter* buf) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MDnsMessage::ShouldUnicastResponse() const {
|
bool MdnsMessage::ShouldUnicastResponse() const {
|
||||||
bool should_unicast = false;
|
bool should_unicast = false;
|
||||||
for (const auto& question : question_section_) {
|
for (const auto& question : question_section_) {
|
||||||
should_unicast |= question.ShouldUnicastResponse();
|
should_unicast |= question.ShouldUnicastResponse();
|
||||||
@ -382,12 +382,12 @@ bool MDnsMessage::ShouldUnicastResponse() const {
|
|||||||
return should_unicast;
|
return should_unicast;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsMessage::AddQuestion(const MDnsQuestion& question) {
|
void MdnsMessage::AddQuestion(const MdnsQuestion& question) {
|
||||||
question_section_.push_back(question);
|
question_section_.push_back(question);
|
||||||
header_.qdcount = question_section_.size();
|
header_.qdcount = question_section_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDnsMessage::AddAnswerRecord(const MDnsResourceRecord& answer) {
|
void MdnsMessage::AddAnswerRecord(const MdnsResourceRecord& answer) {
|
||||||
answer_section_.push_back(answer);
|
answer_section_.push_back(answer);
|
||||||
header_.ancount = answer_section_.size();
|
header_.ancount = answer_section_.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// 6762 and RFC 1025 (DNS messages). Note that it is recommended by RFC 6762 to
|
// 6762 and RFC 1025 (DNS messages). Note that it is recommended by RFC 6762 to
|
||||||
// use the name compression scheme defined in RFC 1035 whenever possible. We
|
// use the name compression scheme defined in RFC 1035 whenever possible. We
|
||||||
// currently only implement the capability of reading compressed names in mDNS
|
// currently only implement the capability of reading compressed names in mDNS
|
||||||
// messages in MDnsMessage::Read(); however, the MDnsMessage::Write() does not
|
// messages in MdnsMessage::Read(); however, the MdnsMessage::Write() does not
|
||||||
// support name compression yet.
|
// support name compression yet.
|
||||||
//
|
//
|
||||||
// Fuzzer tests (test/fuzzers/mdns_parser_fuzzer.cc) MUST always be performed
|
// Fuzzer tests (test/fuzzers/mdns_parser_fuzzer.cc) MUST always be performed
|
||||||
@ -50,7 +50,7 @@ enum class SectionEntryClass {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// RFC 1035, Section 4.1.1.
|
// RFC 1035, Section 4.1.1.
|
||||||
class MDnsHeader final {
|
class MdnsHeader final {
|
||||||
public:
|
public:
|
||||||
bool Read(MessageBufferReader* buf);
|
bool Read(MessageBufferReader* buf);
|
||||||
void Write(rtc::ByteBufferWriter* buf) const;
|
void Write(rtc::ByteBufferWriter* buf) const;
|
||||||
@ -74,11 +74,11 @@ class MDnsHeader final {
|
|||||||
|
|
||||||
// Entries in each section after the header share a common structure. Note that
|
// Entries in each section after the header share a common structure. Note that
|
||||||
// this is not a concept defined in RFC 1035.
|
// this is not a concept defined in RFC 1035.
|
||||||
class MDnsSectionEntry {
|
class MdnsSectionEntry {
|
||||||
public:
|
public:
|
||||||
MDnsSectionEntry();
|
MdnsSectionEntry();
|
||||||
MDnsSectionEntry(const MDnsSectionEntry& other);
|
MdnsSectionEntry(const MdnsSectionEntry& other);
|
||||||
virtual ~MDnsSectionEntry();
|
virtual ~MdnsSectionEntry();
|
||||||
virtual bool Read(MessageBufferReader* buf) = 0;
|
virtual bool Read(MessageBufferReader* buf) = 0;
|
||||||
virtual bool Write(rtc::ByteBufferWriter* buf) const = 0;
|
virtual bool Write(rtc::ByteBufferWriter* buf) const = 0;
|
||||||
|
|
||||||
@ -99,11 +99,11 @@ class MDnsSectionEntry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// RFC 1035, Section 4.1.2.
|
// RFC 1035, Section 4.1.2.
|
||||||
class MDnsQuestion final : public MDnsSectionEntry {
|
class MdnsQuestion final : public MdnsSectionEntry {
|
||||||
public:
|
public:
|
||||||
MDnsQuestion();
|
MdnsQuestion();
|
||||||
MDnsQuestion(const MDnsQuestion& other);
|
MdnsQuestion(const MdnsQuestion& other);
|
||||||
~MDnsQuestion() override;
|
~MdnsQuestion() override;
|
||||||
|
|
||||||
bool Read(MessageBufferReader* buf) override;
|
bool Read(MessageBufferReader* buf) override;
|
||||||
bool Write(rtc::ByteBufferWriter* buf) const override;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
@ -113,11 +113,11 @@ class MDnsQuestion final : public MDnsSectionEntry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// RFC 1035, Section 4.1.3.
|
// RFC 1035, Section 4.1.3.
|
||||||
class MDnsResourceRecord final : public MDnsSectionEntry {
|
class MdnsResourceRecord final : public MdnsSectionEntry {
|
||||||
public:
|
public:
|
||||||
MDnsResourceRecord();
|
MdnsResourceRecord();
|
||||||
MDnsResourceRecord(const MDnsResourceRecord& other);
|
MdnsResourceRecord(const MdnsResourceRecord& other);
|
||||||
~MDnsResourceRecord() override;
|
~MdnsResourceRecord() override;
|
||||||
|
|
||||||
bool Read(MessageBufferReader* buf) override;
|
bool Read(MessageBufferReader* buf) override;
|
||||||
bool Write(rtc::ByteBufferWriter* buf) const override;
|
bool Write(rtc::ByteBufferWriter* buf) const override;
|
||||||
@ -145,17 +145,17 @@ class MDnsResourceRecord final : public MDnsSectionEntry {
|
|||||||
std::string rdata_;
|
std::string rdata_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MDnsMessage final {
|
class MdnsMessage final {
|
||||||
public:
|
public:
|
||||||
// RFC 1035, Section 4.1.
|
// RFC 1035, Section 4.1.
|
||||||
enum class Section { kQuestion, kAnswer, kAuthority, kAdditional };
|
enum class Section { kQuestion, kAnswer, kAuthority, kAdditional };
|
||||||
|
|
||||||
MDnsMessage();
|
MdnsMessage();
|
||||||
~MDnsMessage();
|
~MdnsMessage();
|
||||||
// Reads the mDNS message in |buf| and populates the corresponding fields in
|
// Reads the mDNS message in |buf| and populates the corresponding fields in
|
||||||
// MDnsMessage.
|
// MdnsMessage.
|
||||||
bool Read(MessageBufferReader* buf);
|
bool Read(MessageBufferReader* buf);
|
||||||
// Write an mDNS message to |buf| based on the fields in MDnsMessage.
|
// Write an mDNS message to |buf| based on the fields in MdnsMessage.
|
||||||
//
|
//
|
||||||
// TODO(qingsi): Implement name compression when writing mDNS messages.
|
// TODO(qingsi): Implement name compression when writing mDNS messages.
|
||||||
bool Write(rtc::ByteBufferWriter* buf) const;
|
bool Write(rtc::ByteBufferWriter* buf) const;
|
||||||
@ -177,29 +177,29 @@ class MDnsMessage final {
|
|||||||
// preferred. False otherwise.
|
// preferred. False otherwise.
|
||||||
bool ShouldUnicastResponse() const;
|
bool ShouldUnicastResponse() const;
|
||||||
|
|
||||||
void AddQuestion(const MDnsQuestion& question);
|
void AddQuestion(const MdnsQuestion& question);
|
||||||
// TODO(qingsi): Implement AddXRecord for name server and additional records.
|
// TODO(qingsi): Implement AddXRecord for name server and additional records.
|
||||||
void AddAnswerRecord(const MDnsResourceRecord& answer);
|
void AddAnswerRecord(const MdnsResourceRecord& answer);
|
||||||
|
|
||||||
const std::vector<MDnsQuestion>& question_section() const {
|
const std::vector<MdnsQuestion>& question_section() const {
|
||||||
return question_section_;
|
return question_section_;
|
||||||
}
|
}
|
||||||
const std::vector<MDnsResourceRecord>& answer_section() const {
|
const std::vector<MdnsResourceRecord>& answer_section() const {
|
||||||
return answer_section_;
|
return answer_section_;
|
||||||
}
|
}
|
||||||
const std::vector<MDnsResourceRecord>& authority_section() const {
|
const std::vector<MdnsResourceRecord>& authority_section() const {
|
||||||
return authority_section_;
|
return authority_section_;
|
||||||
}
|
}
|
||||||
const std::vector<MDnsResourceRecord>& additional_section() const {
|
const std::vector<MdnsResourceRecord>& additional_section() const {
|
||||||
return additional_section_;
|
return additional_section_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MDnsHeader header_;
|
MdnsHeader header_;
|
||||||
std::vector<MDnsQuestion> question_section_;
|
std::vector<MdnsQuestion> question_section_;
|
||||||
std::vector<MDnsResourceRecord> answer_section_;
|
std::vector<MdnsResourceRecord> answer_section_;
|
||||||
std::vector<MDnsResourceRecord> authority_section_;
|
std::vector<MdnsResourceRecord> authority_section_;
|
||||||
std::vector<MDnsResourceRecord> additional_section_;
|
std::vector<MdnsResourceRecord> additional_section_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -19,9 +19,9 @@
|
|||||||
#include "rtc_base/socketaddress.h"
|
#include "rtc_base/socketaddress.h"
|
||||||
#include "test/gmock.h"
|
#include "test/gmock.h"
|
||||||
|
|
||||||
#define ReadMDnsMessage(X, Y) ReadMDnsMessageTestCase(X, Y, sizeof(Y))
|
#define ReadMdnsMessage(X, Y) ReadMdnsMessageTestCase(X, Y, sizeof(Y))
|
||||||
#define WriteMDnsMessageAndCompare(X, Y) \
|
#define WriteMdnsMessageAndCompare(X, Y) \
|
||||||
WriteMDnsMessageAndCompareWithTestCast(X, Y, sizeof(Y))
|
WriteMdnsMessageAndCompareWithTestCast(X, Y, sizeof(Y))
|
||||||
|
|
||||||
using ::testing::ElementsAre;
|
using ::testing::ElementsAre;
|
||||||
using ::testing::Pair;
|
using ::testing::Pair;
|
||||||
@ -255,14 +255,14 @@ const uint8_t kCorruptedAnswerWithNameCompression2[] = {
|
|||||||
0xc0, 0xA8, 0x00, 0x01, // 192.168.0.1
|
0xc0, 0xA8, 0x00, 0x01, // 192.168.0.1
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ReadMDnsMessageTestCase(MDnsMessage* msg,
|
bool ReadMdnsMessageTestCase(MdnsMessage* msg,
|
||||||
const uint8_t* testcase,
|
const uint8_t* testcase,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
MessageBufferReader buf(reinterpret_cast<const char*>(testcase), size);
|
MessageBufferReader buf(reinterpret_cast<const char*>(testcase), size);
|
||||||
return msg->Read(&buf);
|
return msg->Read(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteMDnsMessageAndCompareWithTestCast(MDnsMessage* msg,
|
void WriteMdnsMessageAndCompareWithTestCast(MdnsMessage* msg,
|
||||||
const uint8_t* testcase,
|
const uint8_t* testcase,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
rtc::ByteBufferWriter out;
|
rtc::ByteBufferWriter out;
|
||||||
@ -276,7 +276,7 @@ void WriteMDnsMessageAndCompareWithTestCast(MDnsMessage* msg,
|
|||||||
EXPECT_EQ(testcase_bytes, bytes);
|
EXPECT_EQ(testcase_bytes, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetQueriedNames(MDnsMessage* msg, std::set<std::string>* names) {
|
bool GetQueriedNames(MdnsMessage* msg, std::set<std::string>* names) {
|
||||||
if (!msg->IsQuery() || msg->question_section().empty()) {
|
if (!msg->IsQuery() || msg->question_section().empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ bool GetQueriedNames(MDnsMessage* msg, std::set<std::string>* names) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetResolution(MDnsMessage* msg,
|
bool GetResolution(MdnsMessage* msg,
|
||||||
std::map<std::string, rtc::IPAddress>* names) {
|
std::map<std::string, rtc::IPAddress>* names) {
|
||||||
if (msg->IsQuery() || msg->answer_section().empty()) {
|
if (msg->IsQuery() || msg->answer_section().empty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -303,10 +303,10 @@ bool GetResolution(MDnsMessage* msg,
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TEST(MDnsMessageTest, ReadSingleQuestionForIPv4Address) {
|
TEST(MdnsMessageTest, ReadSingleQuestionForIPv4Address) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(
|
||||||
ReadMDnsMessage(&msg, kSingleQuestionForIPv4AddrWithUnicastResponse));
|
ReadMdnsMessage(&msg, kSingleQuestionForIPv4AddrWithUnicastResponse));
|
||||||
EXPECT_TRUE(msg.IsQuery());
|
EXPECT_TRUE(msg.IsQuery());
|
||||||
EXPECT_EQ(0x1234, msg.GetId());
|
EXPECT_EQ(0x1234, msg.GetId());
|
||||||
ASSERT_EQ(1u, msg.question_section().size());
|
ASSERT_EQ(1u, msg.question_section().size());
|
||||||
@ -323,9 +323,9 @@ TEST(MDnsMessageTest, ReadSingleQuestionForIPv4Address) {
|
|||||||
EXPECT_THAT(queried_names, ElementsAre("webrtc.org."));
|
EXPECT_THAT(queried_names, ElementsAre("webrtc.org."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, ReadTwoQuestionsForIPv4AndIPv6Addr) {
|
TEST(MdnsMessageTest, ReadTwoQuestionsForIPv4AndIPv6Addr) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(ReadMDnsMessage(
|
ASSERT_TRUE(ReadMdnsMessage(
|
||||||
&msg, kTwoQuestionsForIPv4AndIPv6AddrWithMulticastResponse));
|
&msg, kTwoQuestionsForIPv4AndIPv6AddrWithMulticastResponse));
|
||||||
EXPECT_TRUE(msg.IsQuery());
|
EXPECT_TRUE(msg.IsQuery());
|
||||||
EXPECT_EQ(0x1234, msg.GetId());
|
EXPECT_EQ(0x1234, msg.GetId());
|
||||||
@ -345,9 +345,9 @@ TEST(MDnsMessageTest, ReadTwoQuestionsForIPv4AndIPv6Addr) {
|
|||||||
UnorderedElementsAre("webrtc4.org.", "webrtc6.org."));
|
UnorderedElementsAre("webrtc4.org.", "webrtc6.org."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, ReadTwoQuestionsForIPv4AndIPv6AddrWithNameCompression) {
|
TEST(MdnsMessageTest, ReadTwoQuestionsForIPv4AndIPv6AddrWithNameCompression) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(ReadMDnsMessage(
|
ASSERT_TRUE(ReadMdnsMessage(
|
||||||
&msg,
|
&msg,
|
||||||
kTwoQuestionsForIPv4AndIPv6AddrWithMulticastResponseAndNameCompression));
|
kTwoQuestionsForIPv4AndIPv6AddrWithMulticastResponseAndNameCompression));
|
||||||
|
|
||||||
@ -363,10 +363,10 @@ TEST(MDnsMessageTest, ReadTwoQuestionsForIPv4AndIPv6AddrWithNameCompression) {
|
|||||||
UnorderedElementsAre("www.webrtc.org.", "mdns.webrtc.org."));
|
UnorderedElementsAre("www.webrtc.org.", "mdns.webrtc.org."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, ReadThreeQuestionsWithTwoPointersToTheSameNameSuffix) {
|
TEST(MdnsMessageTest, ReadThreeQuestionsWithTwoPointersToTheSameNameSuffix) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(
|
||||||
ReadMDnsMessage(&msg, kThreeQuestionsWithTwoPointersToTheSameNameSuffix));
|
ReadMdnsMessage(&msg, kThreeQuestionsWithTwoPointersToTheSameNameSuffix));
|
||||||
|
|
||||||
ASSERT_EQ(3u, msg.question_section().size());
|
ASSERT_EQ(3u, msg.question_section().size());
|
||||||
const auto& question1 = msg.question_section()[0];
|
const auto& question1 = msg.question_section()[0];
|
||||||
@ -383,10 +383,10 @@ TEST(MDnsMessageTest, ReadThreeQuestionsWithTwoPointersToTheSameNameSuffix) {
|
|||||||
"webrtc.org."));
|
"webrtc.org."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest,
|
TEST(MdnsMessageTest,
|
||||||
ReadThreeQuestionsWithPointerToNameSuffixContainingAnotherPointer) {
|
ReadThreeQuestionsWithPointerToNameSuffixContainingAnotherPointer) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(ReadMDnsMessage(
|
ASSERT_TRUE(ReadMdnsMessage(
|
||||||
&msg, kThreeQuestionsWithPointerToNameSuffixContainingAnotherPointer));
|
&msg, kThreeQuestionsWithPointerToNameSuffixContainingAnotherPointer));
|
||||||
|
|
||||||
ASSERT_EQ(3u, msg.question_section().size());
|
ASSERT_EQ(3u, msg.question_section().size());
|
||||||
@ -404,16 +404,16 @@ TEST(MDnsMessageTest,
|
|||||||
"www.mdns.webrtc.org."));
|
"www.mdns.webrtc.org."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest,
|
TEST(MdnsMessageTest,
|
||||||
ReadQuestionWithCorruptedPointerInNameCompressionShouldFail) {
|
ReadQuestionWithCorruptedPointerInNameCompressionShouldFail) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
EXPECT_FALSE(ReadMDnsMessage(&msg, kCorruptedQuestionWithNameCompression1));
|
EXPECT_FALSE(ReadMdnsMessage(&msg, kCorruptedQuestionWithNameCompression1));
|
||||||
EXPECT_FALSE(ReadMDnsMessage(&msg, kCorruptedQuestionWithNameCompression2));
|
EXPECT_FALSE(ReadMdnsMessage(&msg, kCorruptedQuestionWithNameCompression2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, ReadSingleAnswerForIPv4Addr) {
|
TEST(MdnsMessageTest, ReadSingleAnswerForIPv4Addr) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(ReadMDnsMessage(&msg, kSingleAuthoritativeAnswerWithIPv4Addr));
|
ASSERT_TRUE(ReadMdnsMessage(&msg, kSingleAuthoritativeAnswerWithIPv4Addr));
|
||||||
EXPECT_FALSE(msg.IsQuery());
|
EXPECT_FALSE(msg.IsQuery());
|
||||||
EXPECT_TRUE(msg.IsAuthoritative());
|
EXPECT_TRUE(msg.IsAuthoritative());
|
||||||
EXPECT_EQ(0x1234, msg.GetId());
|
EXPECT_EQ(0x1234, msg.GetId());
|
||||||
@ -432,10 +432,10 @@ TEST(MDnsMessageTest, ReadSingleAnswerForIPv4Addr) {
|
|||||||
EXPECT_THAT(resolution, ElementsAre(Pair("webrtc.org.", expected_addr)));
|
EXPECT_THAT(resolution, ElementsAre(Pair("webrtc.org.", expected_addr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, ReadTwoAnswersForIPv4AndIPv6Addr) {
|
TEST(MdnsMessageTest, ReadTwoAnswersForIPv4AndIPv6Addr) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(
|
||||||
ReadMDnsMessage(&msg, kTwoAuthoritativeAnswersWithIPv4AndIPv6Addr));
|
ReadMdnsMessage(&msg, kTwoAuthoritativeAnswersWithIPv4AndIPv6Addr));
|
||||||
EXPECT_FALSE(msg.IsQuery());
|
EXPECT_FALSE(msg.IsQuery());
|
||||||
EXPECT_TRUE(msg.IsAuthoritative());
|
EXPECT_TRUE(msg.IsAuthoritative());
|
||||||
EXPECT_EQ(0x1234, msg.GetId());
|
EXPECT_EQ(0x1234, msg.GetId());
|
||||||
@ -462,9 +462,9 @@ TEST(MDnsMessageTest, ReadTwoAnswersForIPv4AndIPv6Addr) {
|
|||||||
Pair("webrtc6.org.", expected_addr_ipv6)));
|
Pair("webrtc6.org.", expected_addr_ipv6)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, ReadTwoAnswersForIPv4AndIPv6AddrWithNameCompression) {
|
TEST(MdnsMessageTest, ReadTwoAnswersForIPv4AndIPv6AddrWithNameCompression) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
ASSERT_TRUE(ReadMDnsMessage(
|
ASSERT_TRUE(ReadMdnsMessage(
|
||||||
&msg, kTwoAuthoritativeAnswersWithIPv4AndIPv6AddrWithNameCompression));
|
&msg, kTwoAuthoritativeAnswersWithIPv4AndIPv6AddrWithNameCompression));
|
||||||
|
|
||||||
std::map<std::string, rtc::IPAddress> resolution;
|
std::map<std::string, rtc::IPAddress> resolution;
|
||||||
@ -478,57 +478,57 @@ TEST(MDnsMessageTest, ReadTwoAnswersForIPv4AndIPv6AddrWithNameCompression) {
|
|||||||
Pair("webrtc.org.", expected_addr_ipv6)));
|
Pair("webrtc.org.", expected_addr_ipv6)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest,
|
TEST(MdnsMessageTest,
|
||||||
ReadAnswerWithCorruptedPointerInNameCompressionShouldFail) {
|
ReadAnswerWithCorruptedPointerInNameCompressionShouldFail) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
EXPECT_FALSE(ReadMDnsMessage(&msg, kCorruptedAnswerWithNameCompression1));
|
EXPECT_FALSE(ReadMdnsMessage(&msg, kCorruptedAnswerWithNameCompression1));
|
||||||
EXPECT_FALSE(ReadMDnsMessage(&msg, kCorruptedAnswerWithNameCompression2));
|
EXPECT_FALSE(ReadMdnsMessage(&msg, kCorruptedAnswerWithNameCompression2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, WriteSingleQuestionForIPv4Addr) {
|
TEST(MdnsMessageTest, WriteSingleQuestionForIPv4Addr) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
msg.SetId(0x1234);
|
msg.SetId(0x1234);
|
||||||
msg.SetQueryOrResponse(true);
|
msg.SetQueryOrResponse(true);
|
||||||
|
|
||||||
MDnsQuestion question;
|
MdnsQuestion question;
|
||||||
question.SetName("webrtc.org.");
|
question.SetName("webrtc.org.");
|
||||||
question.SetType(SectionEntryType::kA);
|
question.SetType(SectionEntryType::kA);
|
||||||
question.SetClass(SectionEntryClass::kIN);
|
question.SetClass(SectionEntryClass::kIN);
|
||||||
question.SetUnicastResponse(true);
|
question.SetUnicastResponse(true);
|
||||||
msg.AddQuestion(question);
|
msg.AddQuestion(question);
|
||||||
|
|
||||||
WriteMDnsMessageAndCompare(&msg,
|
WriteMdnsMessageAndCompare(&msg,
|
||||||
kSingleQuestionForIPv4AddrWithUnicastResponse);
|
kSingleQuestionForIPv4AddrWithUnicastResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, WriteTwoQuestionsForIPv4AndIPv6Addr) {
|
TEST(MdnsMessageTest, WriteTwoQuestionsForIPv4AndIPv6Addr) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
msg.SetId(0x1234);
|
msg.SetId(0x1234);
|
||||||
msg.SetQueryOrResponse(true);
|
msg.SetQueryOrResponse(true);
|
||||||
|
|
||||||
MDnsQuestion question1;
|
MdnsQuestion question1;
|
||||||
question1.SetName("webrtc4.org.");
|
question1.SetName("webrtc4.org.");
|
||||||
question1.SetType(SectionEntryType::kA);
|
question1.SetType(SectionEntryType::kA);
|
||||||
question1.SetClass(SectionEntryClass::kIN);
|
question1.SetClass(SectionEntryClass::kIN);
|
||||||
msg.AddQuestion(question1);
|
msg.AddQuestion(question1);
|
||||||
|
|
||||||
MDnsQuestion question2;
|
MdnsQuestion question2;
|
||||||
question2.SetName("webrtc6.org.");
|
question2.SetName("webrtc6.org.");
|
||||||
question2.SetType(SectionEntryType::kAAAA);
|
question2.SetType(SectionEntryType::kAAAA);
|
||||||
question2.SetClass(SectionEntryClass::kIN);
|
question2.SetClass(SectionEntryClass::kIN);
|
||||||
msg.AddQuestion(question2);
|
msg.AddQuestion(question2);
|
||||||
|
|
||||||
WriteMDnsMessageAndCompare(
|
WriteMdnsMessageAndCompare(
|
||||||
&msg, kTwoQuestionsForIPv4AndIPv6AddrWithMulticastResponse);
|
&msg, kTwoQuestionsForIPv4AndIPv6AddrWithMulticastResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, WriteSingleAnswerToIPv4Addr) {
|
TEST(MdnsMessageTest, WriteSingleAnswerToIPv4Addr) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
msg.SetId(0x1234);
|
msg.SetId(0x1234);
|
||||||
msg.SetQueryOrResponse(false);
|
msg.SetQueryOrResponse(false);
|
||||||
msg.SetAuthoritative(true);
|
msg.SetAuthoritative(true);
|
||||||
|
|
||||||
MDnsResourceRecord answer;
|
MdnsResourceRecord answer;
|
||||||
answer.SetName("webrtc.org.");
|
answer.SetName("webrtc.org.");
|
||||||
answer.SetType(SectionEntryType::kA);
|
answer.SetType(SectionEntryType::kA);
|
||||||
answer.SetClass(SectionEntryClass::kIN);
|
answer.SetClass(SectionEntryClass::kIN);
|
||||||
@ -537,16 +537,16 @@ TEST(MDnsMessageTest, WriteSingleAnswerToIPv4Addr) {
|
|||||||
answer.SetTtlSeconds(120);
|
answer.SetTtlSeconds(120);
|
||||||
msg.AddAnswerRecord(answer);
|
msg.AddAnswerRecord(answer);
|
||||||
|
|
||||||
WriteMDnsMessageAndCompare(&msg, kSingleAuthoritativeAnswerWithIPv4Addr);
|
WriteMdnsMessageAndCompare(&msg, kSingleAuthoritativeAnswerWithIPv4Addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MDnsMessageTest, WriteTwoAnswersToIPv4AndIPv6Addr) {
|
TEST(MdnsMessageTest, WriteTwoAnswersToIPv4AndIPv6Addr) {
|
||||||
MDnsMessage msg;
|
MdnsMessage msg;
|
||||||
msg.SetId(0x1234);
|
msg.SetId(0x1234);
|
||||||
msg.SetQueryOrResponse(false);
|
msg.SetQueryOrResponse(false);
|
||||||
msg.SetAuthoritative(true);
|
msg.SetAuthoritative(true);
|
||||||
|
|
||||||
MDnsResourceRecord answer1;
|
MdnsResourceRecord answer1;
|
||||||
answer1.SetName("webrtc4.org.");
|
answer1.SetName("webrtc4.org.");
|
||||||
answer1.SetType(SectionEntryType::kA);
|
answer1.SetType(SectionEntryType::kA);
|
||||||
answer1.SetClass(SectionEntryClass::kIN);
|
answer1.SetClass(SectionEntryClass::kIN);
|
||||||
@ -555,7 +555,7 @@ TEST(MDnsMessageTest, WriteTwoAnswersToIPv4AndIPv6Addr) {
|
|||||||
answer1.SetTtlSeconds(60);
|
answer1.SetTtlSeconds(60);
|
||||||
msg.AddAnswerRecord(answer1);
|
msg.AddAnswerRecord(answer1);
|
||||||
|
|
||||||
MDnsResourceRecord answer2;
|
MdnsResourceRecord answer2;
|
||||||
answer2.SetName("webrtc6.org.");
|
answer2.SetName("webrtc6.org.");
|
||||||
answer2.SetType(SectionEntryType::kAAAA);
|
answer2.SetType(SectionEntryType::kAAAA);
|
||||||
answer2.SetClass(SectionEntryClass::kIN);
|
answer2.SetClass(SectionEntryClass::kIN);
|
||||||
@ -564,7 +564,7 @@ TEST(MDnsMessageTest, WriteTwoAnswersToIPv4AndIPv6Addr) {
|
|||||||
answer2.SetTtlSeconds(120);
|
answer2.SetTtlSeconds(120);
|
||||||
msg.AddAnswerRecord(answer2);
|
msg.AddAnswerRecord(answer2);
|
||||||
|
|
||||||
WriteMDnsMessageAndCompare(&msg, kTwoAuthoritativeAnswersWithIPv4AndIPv6Addr);
|
WriteMdnsMessageAndCompare(&msg, kTwoAuthoritativeAnswersWithIPv4AndIPv6Addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -4593,7 +4593,7 @@ TEST(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) {
|
|||||||
// prflx candidate is updated to a host candidate after the name resolution is
|
// prflx candidate is updated to a host candidate after the name resolution is
|
||||||
// done.
|
// done.
|
||||||
TEST_F(P2PTransportChannelTest,
|
TEST_F(P2PTransportChannelTest,
|
||||||
PeerReflexiveCandidateBeforeSignalingWithMDnsName) {
|
PeerReflexiveCandidateBeforeSignalingWithMdnsName) {
|
||||||
rtc::MockAsyncResolver mock_async_resolver;
|
rtc::MockAsyncResolver mock_async_resolver;
|
||||||
webrtc::MockAsyncResolverFactory mock_async_resolver_factory;
|
webrtc::MockAsyncResolverFactory mock_async_resolver_factory;
|
||||||
EXPECT_CALL(mock_async_resolver_factory, Create())
|
EXPECT_CALL(mock_async_resolver_factory, Create())
|
||||||
@ -4604,7 +4604,7 @@ TEST_F(P2PTransportChannelTest,
|
|||||||
ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
|
ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
|
||||||
// ICE parameter will be set up when creating the channels.
|
// ICE parameter will be set up when creating the channels.
|
||||||
set_remote_ice_parameter_source(FROM_SETICEPARAMETERS);
|
set_remote_ice_parameter_source(FROM_SETICEPARAMETERS);
|
||||||
GetEndpoint(0)->network_manager_.CreateMDnsResponder();
|
GetEndpoint(0)->network_manager_.CreateMdnsResponder();
|
||||||
GetEndpoint(1)->async_resolver_factory_ = &mock_async_resolver_factory;
|
GetEndpoint(1)->async_resolver_factory_ = &mock_async_resolver_factory;
|
||||||
CreateChannels();
|
CreateChannels();
|
||||||
// Pause sending candidates from both endpoints until we find out what port
|
// Pause sending candidates from both endpoints until we find out what port
|
||||||
@ -4659,7 +4659,7 @@ TEST_F(P2PTransportChannelTest,
|
|||||||
// a host candidate if the hostname candidate turns out to have the same IP
|
// a host candidate if the hostname candidate turns out to have the same IP
|
||||||
// address after the resolution completes.
|
// address after the resolution completes.
|
||||||
TEST_F(P2PTransportChannelTest,
|
TEST_F(P2PTransportChannelTest,
|
||||||
PeerReflexiveCandidateDuringResolvingHostCandidateWithMDnsName) {
|
PeerReflexiveCandidateDuringResolvingHostCandidateWithMdnsName) {
|
||||||
NiceMock<rtc::MockAsyncResolver> mock_async_resolver;
|
NiceMock<rtc::MockAsyncResolver> mock_async_resolver;
|
||||||
webrtc::MockAsyncResolverFactory mock_async_resolver_factory;
|
webrtc::MockAsyncResolverFactory mock_async_resolver_factory;
|
||||||
EXPECT_CALL(mock_async_resolver_factory, Create())
|
EXPECT_CALL(mock_async_resolver_factory, Create())
|
||||||
@ -4670,7 +4670,7 @@ TEST_F(P2PTransportChannelTest,
|
|||||||
ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
|
ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
|
||||||
// ICE parameter will be set up when creating the channels.
|
// ICE parameter will be set up when creating the channels.
|
||||||
set_remote_ice_parameter_source(FROM_SETICEPARAMETERS);
|
set_remote_ice_parameter_source(FROM_SETICEPARAMETERS);
|
||||||
GetEndpoint(0)->network_manager_.CreateMDnsResponder();
|
GetEndpoint(0)->network_manager_.CreateMdnsResponder();
|
||||||
GetEndpoint(1)->async_resolver_factory_ = &mock_async_resolver_factory;
|
GetEndpoint(1)->async_resolver_factory_ = &mock_async_resolver_factory;
|
||||||
CreateChannels();
|
CreateChannels();
|
||||||
// Pause sending candidates from both endpoints until we find out what port
|
// Pause sending candidates from both endpoints until we find out what port
|
||||||
@ -4726,7 +4726,7 @@ TEST_F(P2PTransportChannelTest,
|
|||||||
// Test that if we only gather and signal a host candidate, the IP address of
|
// Test that if we only gather and signal a host candidate, the IP address of
|
||||||
// which is obfuscated by an mDNS name, and if the peer can complete the name
|
// which is obfuscated by an mDNS name, and if the peer can complete the name
|
||||||
// resolution with the correct IP address, we can have a p2p connection.
|
// resolution with the correct IP address, we can have a p2p connection.
|
||||||
TEST_F(P2PTransportChannelTest, CanConnectWithHostCandidateWithMDnsName) {
|
TEST_F(P2PTransportChannelTest, CanConnectWithHostCandidateWithMdnsName) {
|
||||||
NiceMock<rtc::MockAsyncResolver> mock_async_resolver;
|
NiceMock<rtc::MockAsyncResolver> mock_async_resolver;
|
||||||
webrtc::MockAsyncResolverFactory mock_async_resolver_factory;
|
webrtc::MockAsyncResolverFactory mock_async_resolver_factory;
|
||||||
EXPECT_CALL(mock_async_resolver_factory, Create())
|
EXPECT_CALL(mock_async_resolver_factory, Create())
|
||||||
@ -4737,7 +4737,7 @@ TEST_F(P2PTransportChannelTest, CanConnectWithHostCandidateWithMDnsName) {
|
|||||||
ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
|
ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
|
||||||
// ICE parameter will be set up when creating the channels.
|
// ICE parameter will be set up when creating the channels.
|
||||||
set_remote_ice_parameter_source(FROM_SETICEPARAMETERS);
|
set_remote_ice_parameter_source(FROM_SETICEPARAMETERS);
|
||||||
GetEndpoint(0)->network_manager_.CreateMDnsResponder();
|
GetEndpoint(0)->network_manager_.CreateMdnsResponder();
|
||||||
GetEndpoint(1)->async_resolver_factory_ = &mock_async_resolver_factory;
|
GetEndpoint(1)->async_resolver_factory_ = &mock_async_resolver_factory;
|
||||||
CreateChannels();
|
CreateChannels();
|
||||||
// Pause sending candidates from both endpoints until we find out what port
|
// Pause sending candidates from both endpoints until we find out what port
|
||||||
|
|||||||
@ -432,7 +432,7 @@ void Port::AddAddress(const rtc::SocketAddress& address,
|
|||||||
c.set_url(url);
|
c.set_url(url);
|
||||||
// TODO(bugs.webrtc.org/9723): Use a config to control the feature of IP
|
// TODO(bugs.webrtc.org/9723): Use a config to control the feature of IP
|
||||||
// handling with mDNS.
|
// handling with mDNS.
|
||||||
if (network_->GetMDnsResponder() != nullptr) {
|
if (network_->GetMdnsResponder() != nullptr) {
|
||||||
// Obfuscate the IP address of a host candidates by an mDNS hostname.
|
// Obfuscate the IP address of a host candidates by an mDNS hostname.
|
||||||
if (type == LOCAL_PORT_TYPE) {
|
if (type == LOCAL_PORT_TYPE) {
|
||||||
auto weak_ptr = weak_factory_.GetWeakPtr();
|
auto weak_ptr = weak_factory_.GetWeakPtr();
|
||||||
@ -451,7 +451,7 @@ void Port::AddAddress(const rtc::SocketAddress& address,
|
|||||||
weak_ptr->FinishAddingAddress(c, is_final);
|
weak_ptr->FinishAddingAddress(c, is_final);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
network_->GetMDnsResponder()->CreateNameForAddress(c.address().ipaddr(),
|
network_->GetMdnsResponder()->CreateNameForAddress(c.address().ipaddr(),
|
||||||
callback);
|
callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2258,7 +2258,7 @@ TEST_F(BasicPortAllocatorTest, HostCandidateAddressIsReplacedByHostname) {
|
|||||||
AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr);
|
AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr);
|
||||||
|
|
||||||
ASSERT_EQ(&network_manager_, allocator().network_manager());
|
ASSERT_EQ(&network_manager_, allocator().network_manager());
|
||||||
network_manager_.CreateMDnsResponder();
|
network_manager_.CreateMdnsResponder();
|
||||||
AddInterface(kClientAddr);
|
AddInterface(kClientAddr);
|
||||||
ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
|
ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
|
||||||
session_->StartGettingPorts();
|
session_->StartGettingPorts();
|
||||||
|
|||||||
@ -360,9 +360,12 @@ PeerConnectionFactory::CreatePeerConnection(
|
|||||||
network_thread_);
|
network_thread_);
|
||||||
}
|
}
|
||||||
if (!dependencies.allocator) {
|
if (!dependencies.allocator) {
|
||||||
dependencies.allocator.reset(new cricket::BasicPortAllocator(
|
network_thread_->Invoke<void>(RTC_FROM_HERE, [this, &configuration,
|
||||||
default_network_manager_.get(), default_socket_factory_.get(),
|
&dependencies]() {
|
||||||
configuration.turn_customizer));
|
dependencies.allocator = absl::make_unique<cricket::BasicPortAllocator>(
|
||||||
|
default_network_manager_.get(), default_socket_factory_.get(),
|
||||||
|
configuration.turn_customizer);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(zstein): Once chromium injects its own AsyncResolverFactory, set
|
// TODO(zstein): Once chromium injects its own AsyncResolverFactory, set
|
||||||
|
|||||||
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class FakeMDnsResponder : public MDnsResponderInterface {
|
class FakeMdnsResponder : public MdnsResponderInterface {
|
||||||
public:
|
public:
|
||||||
FakeMDnsResponder() = default;
|
FakeMdnsResponder() = default;
|
||||||
~FakeMDnsResponder() = default;
|
~FakeMdnsResponder() = default;
|
||||||
|
|
||||||
void CreateNameForAddress(const rtc::IPAddress& addr,
|
void CreateNameForAddress(const rtc::IPAddress& addr,
|
||||||
NameCreatedCallback callback) override {
|
NameCreatedCallback callback) override {
|
||||||
|
|||||||
@ -82,16 +82,16 @@ class FakeNetworkManager : public NetworkManagerBase, public MessageHandler {
|
|||||||
// MessageHandler interface.
|
// MessageHandler interface.
|
||||||
virtual void OnMessage(Message* msg) { DoUpdateNetworks(); }
|
virtual void OnMessage(Message* msg) { DoUpdateNetworks(); }
|
||||||
|
|
||||||
void CreateMDnsResponder() {
|
void CreateMdnsResponder() {
|
||||||
if (mdns_responder_ == nullptr) {
|
if (mdns_responder_ == nullptr) {
|
||||||
mdns_responder_ = absl::make_unique<webrtc::FakeMDnsResponder>();
|
mdns_responder_ = absl::make_unique<webrtc::FakeMdnsResponder>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using NetworkManagerBase::set_enumeration_permission;
|
using NetworkManagerBase::set_enumeration_permission;
|
||||||
using NetworkManagerBase::set_default_local_addresses;
|
using NetworkManagerBase::set_default_local_addresses;
|
||||||
|
|
||||||
webrtc::MDnsResponderInterface* GetMDnsResponder() const override {
|
webrtc::MdnsResponderInterface* GetMdnsResponder() const override {
|
||||||
return mdns_responder_.get();
|
return mdns_responder_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class FakeNetworkManager : public NetworkManagerBase, public MessageHandler {
|
|||||||
IPAddress default_local_ipv4_address_;
|
IPAddress default_local_ipv4_address_;
|
||||||
IPAddress default_local_ipv6_address_;
|
IPAddress default_local_ipv6_address_;
|
||||||
|
|
||||||
std::unique_ptr<webrtc::FakeMDnsResponder> mdns_responder_;
|
std::unique_ptr<webrtc::FakeMdnsResponder> mdns_responder_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace rtc
|
} // namespace rtc
|
||||||
|
|||||||
@ -12,36 +12,35 @@
|
|||||||
#define RTC_BASE_MDNS_RESPONDER_INTERFACE_H_
|
#define RTC_BASE_MDNS_RESPONDER_INTERFACE_H_
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <set>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "rtc_base/ipaddress.h"
|
#include "rtc_base/ipaddress.h"
|
||||||
#include "rtc_base/socketaddress.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// Defines an mDNS responder that can be used in ICE candidate gathering, where
|
// Defines an mDNS responder that can be used in ICE candidate gathering, where
|
||||||
// the local IP addresses of host candidates are obfuscated by mDNS hostnames.
|
// the local IP addresses of host candidates are replaced by mDNS hostnames.
|
||||||
class MDnsResponderInterface {
|
class MdnsResponderInterface {
|
||||||
public:
|
public:
|
||||||
using NameCreatedCallback =
|
using NameCreatedCallback =
|
||||||
std::function<void(const rtc::IPAddress&, const std::string&)>;
|
std::function<void(const rtc::IPAddress&, const std::string&)>;
|
||||||
using NameRemovedCallback = std::function<void(bool)>;
|
using NameRemovedCallback = std::function<void(bool)>;
|
||||||
|
|
||||||
MDnsResponderInterface() = default;
|
MdnsResponderInterface() = default;
|
||||||
virtual ~MDnsResponderInterface() = default;
|
virtual ~MdnsResponderInterface() = default;
|
||||||
|
|
||||||
// Asynchronously creates a type-4 UUID hostname for an IP address. The
|
// Asynchronously creates and returns a new name via |callback| for |addr| if
|
||||||
// created name should be given to |callback| with the address that it
|
// there is no name mapped to it by this responder, and initializes the
|
||||||
// represents.
|
// reference count of this name to one. Otherwise the existing name mapped to
|
||||||
|
// |addr| is returned and its reference count is incremented by one.
|
||||||
virtual void CreateNameForAddress(const rtc::IPAddress& addr,
|
virtual void CreateNameForAddress(const rtc::IPAddress& addr,
|
||||||
NameCreatedCallback callback) = 0;
|
NameCreatedCallback callback) = 0;
|
||||||
// Removes the name mapped to the given address if there is such an
|
// Decrements the reference count of the mapped name of |addr|, if
|
||||||
// name-address mapping previously created via CreateNameForAddress. The
|
// there is a map created previously via CreateNameForAddress; asynchronously
|
||||||
// result of whether an associated name-address mapping is removed should be
|
// removes the association between |addr| and its mapped name, and returns
|
||||||
// given to |callback|.
|
// true via |callback| if the decremented reference count reaches zero.
|
||||||
|
// Otherwise no operation is done and false is returned via |callback|
|
||||||
|
// asynchronously.
|
||||||
virtual void RemoveNameForAddress(const rtc::IPAddress& addr,
|
virtual void RemoveNameForAddress(const rtc::IPAddress& addr,
|
||||||
NameRemovedCallback callback) = 0;
|
NameRemovedCallback callback) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -259,7 +259,7 @@ bool NetworkManager::GetDefaultLocalAddress(int family, IPAddress* addr) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
webrtc::MDnsResponderInterface* NetworkManager::GetMDnsResponder() const {
|
webrtc::MdnsResponderInterface* NetworkManager::GetMdnsResponder() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
|
|||||||
new rtc::Network("any", "any", ipv4_any_address, 0, ADAPTER_TYPE_ANY));
|
new rtc::Network("any", "any", ipv4_any_address, 0, ADAPTER_TYPE_ANY));
|
||||||
ipv4_any_address_network_->set_default_local_address_provider(this);
|
ipv4_any_address_network_->set_default_local_address_provider(this);
|
||||||
ipv4_any_address_network_->AddIP(ipv4_any_address);
|
ipv4_any_address_network_->AddIP(ipv4_any_address);
|
||||||
ipv4_any_address_network_->SetMDnsResponder(GetMDnsResponder());
|
ipv4_any_address_network_->SetMdnsResponder(GetMdnsResponder());
|
||||||
}
|
}
|
||||||
networks->push_back(ipv4_any_address_network_.get());
|
networks->push_back(ipv4_any_address_network_.get());
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
|
|||||||
"any", "any", ipv6_any_address, 0, ADAPTER_TYPE_ANY));
|
"any", "any", ipv6_any_address, 0, ADAPTER_TYPE_ANY));
|
||||||
ipv6_any_address_network_->set_default_local_address_provider(this);
|
ipv6_any_address_network_->set_default_local_address_provider(this);
|
||||||
ipv6_any_address_network_->AddIP(ipv6_any_address);
|
ipv6_any_address_network_->AddIP(ipv6_any_address);
|
||||||
ipv6_any_address_network_->SetMDnsResponder(GetMDnsResponder());
|
ipv6_any_address_network_->SetMdnsResponder(GetMdnsResponder());
|
||||||
}
|
}
|
||||||
networks->push_back(ipv6_any_address_network_.get());
|
networks->push_back(ipv6_any_address_network_.get());
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
|
|||||||
delete net;
|
delete net;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
networks_map_[key]->SetMDnsResponder(GetMDnsResponder());
|
networks_map_[key]->SetMdnsResponder(GetMdnsResponder());
|
||||||
}
|
}
|
||||||
// It may still happen that the merged list is a subset of |networks_|.
|
// It may still happen that the merged list is a subset of |networks_|.
|
||||||
// To detect this change, we compare their sizes.
|
// To detect this change, we compare their sizes.
|
||||||
|
|||||||
@ -141,7 +141,7 @@ class NetworkManager : public DefaultLocalAddressProvider {
|
|||||||
|
|
||||||
// Returns the mDNS responder that can be used to obfuscate the local IP
|
// Returns the mDNS responder that can be used to obfuscate the local IP
|
||||||
// addresses of ICE host candidates by mDNS hostnames.
|
// addresses of ICE host candidates by mDNS hostnames.
|
||||||
virtual webrtc::MDnsResponderInterface* GetMDnsResponder() const;
|
virtual webrtc::MdnsResponderInterface* GetMdnsResponder() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Base class for NetworkManager implementations.
|
// Base class for NetworkManager implementations.
|
||||||
@ -367,11 +367,11 @@ class Network {
|
|||||||
// created name will be resolved by the responder.
|
// created name will be resolved by the responder.
|
||||||
//
|
//
|
||||||
// The mDNS responder, if not null, should outlive this rtc::Network.
|
// The mDNS responder, if not null, should outlive this rtc::Network.
|
||||||
void SetMDnsResponder(webrtc::MDnsResponderInterface* mdns_responder) {
|
void SetMdnsResponder(webrtc::MdnsResponderInterface* mdns_responder) {
|
||||||
mdns_responder_ = mdns_responder;
|
mdns_responder_ = mdns_responder;
|
||||||
}
|
}
|
||||||
// Returns the mDNS responder, which is null by default.
|
// Returns the mDNS responder, which is null by default.
|
||||||
webrtc::MDnsResponderInterface* GetMDnsResponder() const {
|
webrtc::MdnsResponderInterface* GetMdnsResponder() const {
|
||||||
return mdns_responder_;
|
return mdns_responder_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ class Network {
|
|||||||
int prefix_length_;
|
int prefix_length_;
|
||||||
std::string key_;
|
std::string key_;
|
||||||
std::vector<InterfaceAddress> ips_;
|
std::vector<InterfaceAddress> ips_;
|
||||||
webrtc::MDnsResponderInterface* mdns_responder_ = nullptr;
|
webrtc::MdnsResponderInterface* mdns_responder_ = nullptr;
|
||||||
int scope_id_;
|
int scope_id_;
|
||||||
bool ignored_;
|
bool ignored_;
|
||||||
AdapterType type_;
|
AdapterType type_;
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
void FuzzOneInput(const uint8_t* data, size_t size) {
|
void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||||
MessageBufferReader buf(reinterpret_cast<const char*>(data), size);
|
MessageBufferReader buf(reinterpret_cast<const char*>(data), size);
|
||||||
auto mdns_msg = absl::make_unique<MDnsMessage>();
|
auto mdns_msg = absl::make_unique<MdnsMessage>();
|
||||||
mdns_msg->Read(&buf);
|
mdns_msg->Read(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user