packet-parsing #1

Open
pentapiper wants to merge 5 commits from packet-parsing into main
Showing only changes of commit 2c24b6d723 - Show all commits

View file

@ -3,36 +3,6 @@
#include "dns_request.h" #include "dns_request.h"
/*
* get k'th bit from byte c
* because of how the DNS spec works, this starts counting from the LEFTMOST bit.
*/
// unsigned int get_bit(unsigned char c, unsigned int k)
// {
// unsigned int flag = 1U; // flag = 0000.....00001
//
// flag = flag << (8U-k); // flag = 0000...010...000 (shifted k positions)
//
// return c & flag;
// }
/*
* get n bits from byte c starting at position k
* because of how the DNS spec works, this starts counting from the LEFTMOST bit.
*/
// unsigned int get_bits(unsigned char c, unsigned int n, unsigned int k)
// {
// unsigned int ret = 0;
// unsigned int flag = 1U; // flag = 0000.....00001
//
// for (int j = 0; j < n; j++) {
// unsigned int bit_pos = 8U - k + j;
// ret = ret | get_bit(c, k+j) << bit_pos;
// }
//
// return ret;
// }
struct DNSRequest *parse_dns_query(struct DNSPacketBuffer *pb) struct DNSRequest *parse_dns_query(struct DNSPacketBuffer *pb)
{ {
struct DNSRequest *req; struct DNSRequest *req;