2023-10-26 16:02:34 -04:00
|
|
|
/*
|
|
|
|
* Global constants file.
|
2023-10-27 02:18:05 -04:00
|
|
|
* Copyright (C) 2023 Brett Terpstra, Et al
|
2023-10-26 16:02:34 -04:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSANE_DNS_CONSTANTS_H
|
|
|
|
#define INSANE_DNS_CONSTANTS_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* --------------------------------------------
|
|
|
|
* | Magic Number Constants |
|
|
|
|
* --------------------------------------------
|
|
|
|
*/
|
2023-10-27 02:18:05 -04:00
|
|
|
|
|
|
|
static constexpr size_t PACKET_BUFFER_SIZE = 65535;
|
|
|
|
|
|
|
|
/*
|
2023-10-27 14:46:56 -04:00
|
|
|
* These structs are used in combination with templates to create polymorphism between the UDP and TCP implementation.
|
|
|
|
* this design decision has significantly reduced the code reuse while not introducing any runtime overhead.
|
2023-10-27 02:18:05 -04:00
|
|
|
* The data set within these structures are specific to the protocol they implement. UDP is exactly as specified in the RFC spec
|
|
|
|
* TCP is what I observed from wireshark (+2 byte offset)
|
|
|
|
*/
|
|
|
|
struct DNS_UDP_INFO_t
|
|
|
|
{
|
|
|
|
/** DNS header data offset. This is the first byte that isn't a header value (should be question label length octet) */
|
|
|
|
size_t HEADER_END = 12;
|
|
|
|
/** DNS questions count data offset. In the standard header this is 4 bytes in */
|
|
|
|
size_t QUESTIONS_BEGIN = 4;
|
|
|
|
/** DNS answer count data offset. */
|
|
|
|
size_t ANSWERS_BEGIN = 6;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The TCP version appears to use a 2 byte unsigned short to represent length. This struct accounts for that.
|
|
|
|
*/
|
|
|
|
struct DNS_TCP_INFO_t
|
|
|
|
{
|
|
|
|
size_t HEADER_END = 14;
|
|
|
|
size_t QUESTIONS_BEGIN = 6;
|
|
|
|
size_t ANSWERS_BEGIN = 8;
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr DNS_UDP_INFO_t DNS_UDP_INFO;
|
|
|
|
static constexpr DNS_TCP_INFO_t DNS_TCP_INFO;
|
2023-10-26 16:02:34 -04:00
|
|
|
|
|
|
|
#endif //INSANE_DNS_CONSTANTS_H
|