2023-04-06 03:08:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "question.h"
|
|
|
|
#include "header.h"
|
|
|
|
#include "record.h"
|
|
|
|
#include "../server/addr.h"
|
|
|
|
|
2023-04-11 13:27:16 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2023-04-06 03:08:09 +00:00
|
|
|
typedef struct {
|
|
|
|
Header header;
|
|
|
|
Question* questions;
|
|
|
|
Record* answers;
|
|
|
|
Record* authorities;
|
|
|
|
Record* resources;
|
|
|
|
} Packet;
|
|
|
|
|
|
|
|
void read_packet(PacketBuffer* buffer, Packet* packet);
|
|
|
|
void write_packet(PacketBuffer* buffer, Packet* packet);
|
|
|
|
void free_packet(Packet* packet);
|
|
|
|
|
|
|
|
bool get_random_a(Packet* packet, IpAddr* addr);
|
|
|
|
bool get_resolved_ns(Packet* packet, uint8_t* qname, IpAddr* addr);
|
|
|
|
bool get_unresoled_ns(Packet* packet, uint8_t* qname, Question* question);
|