mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:38:13 +00:00
LookupServer: Turn #defines into enum classes and add formatter
This commit is contained in:
parent
6e70888315
commit
7b3bed7910
11 changed files with 120 additions and 49 deletions
|
@ -5,11 +5,12 @@
|
|||
*/
|
||||
|
||||
#include "DNSAnswer.h"
|
||||
#include <AK/Stream.h>
|
||||
#include <time.h>
|
||||
|
||||
namespace LookupServer {
|
||||
|
||||
DNSAnswer::DNSAnswer(const DNSName& name, u16 type, u16 class_code, u32 ttl, const String& record_data, bool mdns_cache_flush)
|
||||
DNSAnswer::DNSAnswer(const DNSName& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, const String& record_data, bool mdns_cache_flush)
|
||||
: m_name(name)
|
||||
, m_type(type)
|
||||
, m_class_code(class_code)
|
||||
|
@ -29,3 +30,42 @@ bool DNSAnswer::has_expired() const
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
void AK::Formatter<LookupServer::DNSRecordType>::format(AK::FormatBuilder& builder, LookupServer::DNSRecordType value)
|
||||
{
|
||||
switch (value) {
|
||||
case LookupServer::DNSRecordType::A:
|
||||
builder.put_string("A");
|
||||
return;
|
||||
case LookupServer::DNSRecordType::NS:
|
||||
builder.put_string("NS");
|
||||
return;
|
||||
case LookupServer::DNSRecordType::CNAME:
|
||||
builder.put_string("CNAME");
|
||||
return;
|
||||
case LookupServer::DNSRecordType::SOA:
|
||||
builder.put_string("SOA");
|
||||
return;
|
||||
case LookupServer::DNSRecordType::PTR:
|
||||
builder.put_string("PTR");
|
||||
return;
|
||||
case LookupServer::DNSRecordType::MX:
|
||||
builder.put_string("MX");
|
||||
return;
|
||||
}
|
||||
|
||||
builder.put_string("DNS record type ");
|
||||
builder.put_u64((u16)value);
|
||||
}
|
||||
|
||||
void AK::Formatter<LookupServer::DNSRecordClass>::format(AK::FormatBuilder& builder, LookupServer::DNSRecordClass value)
|
||||
{
|
||||
switch (value) {
|
||||
case LookupServer::DNSRecordClass::IN:
|
||||
builder.put_string("IN");
|
||||
return;
|
||||
}
|
||||
|
||||
builder.put_string("DNS record class ");
|
||||
builder.put_u64((u16)value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue