summaryrefslogtreecommitdiff
path: root/Userland/Services/LookupServer
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-07 23:55:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-10 17:26:17 +0200
commit3304d675e1c02c1e0fe857ca94f85cece8f2d837 (patch)
tree8d25daaf71fd3df1566aeda84d3bf824f447d87f /Userland/Services/LookupServer
parentc160c6b035ac86d53860631269d0f614b5f209a9 (diff)
downloadserenity-3304d675e1c02c1e0fe857ca94f85cece8f2d837.zip
LookupServer: Correct some flags for DNS packets
This corrects some of the flags in the DNS packets to match what I saw on my local network.
Diffstat (limited to 'Userland/Services/LookupServer')
-rw-r--r--Userland/Services/LookupServer/DNSPacket.cpp5
-rw-r--r--Userland/Services/LookupServer/DNSPacket.h9
-rw-r--r--Userland/Services/LookupServer/MulticastDNS.cpp4
3 files changed, 16 insertions, 2 deletions
diff --git a/Userland/Services/LookupServer/DNSPacket.cpp b/Userland/Services/LookupServer/DNSPacket.cpp
index f7f67f0dcb..21a3c647f2 100644
--- a/Userland/Services/LookupServer/DNSPacket.cpp
+++ b/Userland/Services/LookupServer/DNSPacket.cpp
@@ -40,13 +40,14 @@ ByteBuffer DNSPacket::to_byte_buffer() const
header.set_is_query();
else
header.set_is_response();
+ header.set_authoritative_answer(m_authoritative_answer);
// FIXME: What should this be?
header.set_opcode(0);
header.set_response_code(m_code);
header.set_truncated(false); // hopefully...
- header.set_recursion_desired(true);
+ header.set_recursion_desired(m_recursion_desired);
// FIXME: what should the be for requests?
- header.set_recursion_available(true);
+ header.set_recursion_available(m_recursion_available);
header.set_question_count(m_questions.size());
header.set_answer_count(m_answers.size());
diff --git a/Userland/Services/LookupServer/DNSPacket.h b/Userland/Services/LookupServer/DNSPacket.h
index 0927f94e4f..7a3cd57827 100644
--- a/Userland/Services/LookupServer/DNSPacket.h
+++ b/Userland/Services/LookupServer/DNSPacket.h
@@ -29,8 +29,14 @@ public:
bool is_query() const { return !m_query_or_response; }
bool is_response() const { return m_query_or_response; }
+ bool is_authoritative_answer() const { return m_authoritative_answer; }
+ bool recursion_desired() const { return m_recursion_desired; }
+ bool recursion_available() const { return m_recursion_available; }
void set_is_query() { m_query_or_response = false; }
void set_is_response() { m_query_or_response = true; }
+ void set_authoritative_answer(bool authoritative_answer) { m_authoritative_answer = authoritative_answer; }
+ void set_recursion_desired(bool recursion_desired) { m_recursion_desired = recursion_desired; }
+ void set_recursion_available(bool recursion_available) { m_recursion_available = recursion_available; }
u16 id() const { return m_id; }
void set_id(u16 id) { m_id = id; }
@@ -72,7 +78,10 @@ public:
private:
u16 m_id { 0 };
u8 m_code { 0 };
+ bool m_authoritative_answer { false };
bool m_query_or_response { false };
+ bool m_recursion_desired { true };
+ bool m_recursion_available { true };
Vector<DNSQuestion> m_questions;
Vector<DNSAnswer> m_answers;
};
diff --git a/Userland/Services/LookupServer/MulticastDNS.cpp b/Userland/Services/LookupServer/MulticastDNS.cpp
index 2eebfbf1f4..93223d4bd2 100644
--- a/Userland/Services/LookupServer/MulticastDNS.cpp
+++ b/Userland/Services/LookupServer/MulticastDNS.cpp
@@ -82,6 +82,9 @@ void MulticastDNS::announce()
DNSPacket response;
response.set_is_response();
response.set_code(DNSPacket::Code::NOERROR);
+ response.set_authoritative_answer(true);
+ response.set_recursion_desired(false);
+ response.set_recursion_available(false);
for (auto& address : local_addresses()) {
auto raw_addr = address.to_in_addr_t();
@@ -142,6 +145,7 @@ Vector<DNSAnswer> MulticastDNS::lookup(const DNSName& name, DNSRecordType record
{
DNSPacket request;
request.set_is_query();
+ request.set_recursion_desired(false);
request.add_question({ name, record_type, DNSRecordClass::IN, false });
if (emit_packet(request) < 0) {