read the packets into packet structs

This commit is contained in:
Piper Pentagram 2025-07-08 15:36:27 -07:00
parent f1e00117d9
commit 68400a25b7
5 changed files with 53 additions and 4 deletions

View file

@ -1,13 +1,16 @@
#pragma once
#include <stddef.h>
#define PACKET_BUFFER_SIZE 512
#define PB_SIZE 512
#define PB_OUT_OF_BOUNDS 9999;
struct DNSPacketBuffer {
char buf[PACKET_BUFFER_SIZE];
char buf[PB_SIZE];
size_t pos;
};
struct DNSPacketBuffer *new_dns_packet_buffer();
struct DNSPacketHeader *dns_header(struct DNSPacketBuffer);
char pb_read_byte(struct DNSPacketBuffer *);

View file

@ -1,7 +1,10 @@
#pragma once
#include "dns_packets.h"
#include "dns_packet_buffer.h"
struct DNSRequest {
struct DNSPacketHeader header;
struct DNSPacketHeader *header;
};
struct DNSRequest *new_dns_request(struct DNSPacketBuffer *pb);

View file

@ -1,5 +1,5 @@
#pragma once
#define UDP_PORT 53
#define UDP_PORT 1053
int start_server();