mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
LookupServer: Minor overhaul
- Break out request building into a DNSRequest class. - Break out response parsing into a DNSResponse class. A DNSRequest contains one or more DNSQuestion objects. A DNSResponse contains all the DNSQuestions asked, and a DNSAnswer object for each answer.
This commit is contained in:
parent
f24173b0f1
commit
871b6b4e1a
10 changed files with 343 additions and 181 deletions
33
Servers/LookupServer/DNSRequest.h
Normal file
33
Servers/LookupServer/DNSRequest.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include "DNSQuestion.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
#define T_A 1
|
||||
#define T_NS 2
|
||||
#define T_CNAME 5
|
||||
#define T_SOA 6
|
||||
#define T_PTR 12
|
||||
#define T_MX 15
|
||||
|
||||
class DNSRequest {
|
||||
public:
|
||||
DNSRequest();
|
||||
|
||||
void add_question(const String& name, u16 record_type);
|
||||
|
||||
u16 question_count() const
|
||||
{
|
||||
ASSERT(m_questions.size() < UINT16_MAX);
|
||||
return m_questions.size();
|
||||
}
|
||||
|
||||
u16 id() const { return m_id; }
|
||||
ByteBuffer to_byte_buffer() const;
|
||||
|
||||
private:
|
||||
u16 m_id { 0 };
|
||||
Vector<DNSQuestion> m_questions;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue