Three more helper functions and the DNS action is done.

This commit is contained in:
Meredith L. Patterson 2012-05-26 13:16:34 +02:00
parent 8959d6db07
commit 595404e175
3 changed files with 122 additions and 6 deletions

View file

@ -1,7 +1,8 @@
typedef int bool;
struct dns_header {
uint16_t id;
boolean qr, aa, tc, rd, ra;
char opcode, z, rcode;
bool qr, aa, tc, rd, ra;
char opcode, rcode;
size_t question_count;
size_t answer_count;
size_t authority_count;
@ -19,14 +20,54 @@ struct dns_rr {
uint32_t ttl; // cmos is also acceptable.
uint16_t rdlength;
union {
// various types of rdata-specific data here...
char* cname;
struct {
uint8_t* cpu;
uint8_t* os;
} hinfo;
char* mb;
char* md;
char* mf;
char* mg;
struct {
char* rmailbx;
char* emailbx;
} minfo;
char* mr;
struct {
uint16_t preference;
char* exchange;
} mx;
uint8_t* null;
char* ns;
char* ptr;
struct {
char* mname;
char* rname;
uint32_t serial;
uint32_t refresh;
uint32_t retry;
uint32_t expire;
uint32_t minimum;
} soa;
struct {
size_t count;
uint8_t** txt_data;
} txt;
uint32_t a;
struct {
uint32_t address;
uint8_t protocol;
size_t len;
uint8_t** bit_map;
} wks;
};
};
typedef struct dns_message {
struct dns_header header;
struct dns_question *questions; // end all these with null, just to be sure.
struct dns_question *questions;
struct dns_rr *answers;
struct dns_rr *authority;
struct dns_rr *additional;
}
} dns_message_t;