summaryrefslogtreecommitdiff
path: root/Userland/Services/LookupServer/DNSQuestion.h
blob: dfe5826b55a2877c1e63c8d6c23bcfcdd7bf4d84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "DNSName.h"
#include <AK/Types.h>

namespace LookupServer {

#define MDNS_WANTS_UNICAST_RESPONSE 0x8000

class DNSQuestion {
public:
    DNSQuestion(const DNSName& name, u16 record_type, u16 class_code, bool mdns_wants_unicast_response)
        : m_name(name)
        , m_record_type(record_type)
        , m_class_code(class_code)
        , m_mdns_wants_unicast_response(mdns_wants_unicast_response)
    {
    }

    u16 record_type() const { return m_record_type; }
    u16 class_code() const { return m_class_code; }
    u16 raw_class_code() const { return (u16)m_class_code | (m_mdns_wants_unicast_response ? MDNS_WANTS_UNICAST_RESPONSE : 0); }
    const DNSName& name() const { return m_name; }
    bool mdns_wants_unicast_response() const { return m_mdns_wants_unicast_response; }

private:
    DNSName m_name;
    u16 m_record_type { 0 };
    u16 m_class_code { 0 };
    bool m_mdns_wants_unicast_response { false };
};

}