Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,18 @@ bool dns_packet_question(const char *name, int type)
return true;
}

void dns_packet_answer(const char *name, int type, const uint8_t *rdata, uint16_t rdlength, int ttl)
bool dns_packet_answer(const char *name, int type, const uint8_t *rdata, uint16_t rdlength, int ttl)
{
struct dns_answer *a;

pkt.h.flags |= cpu_to_be16(0x8400);

a = dns_packet_record_add(sizeof(*a) + rdlength, name);
if (!a) {
DBG(0, "Not enough room for answer %d\n", be16_to_cpu(pkt.h.answers)+1);
return false;
}

memset(a, 0, sizeof(*a));
a->type = cpu_to_be16(type);
a->class = cpu_to_be16(1);
Expand All @@ -166,6 +171,7 @@ void dns_packet_answer(const char *name, int type, const uint8_t *rdata, uint16_
DBG(1, "A <- %s %s\n", dns_type_string(be16_to_cpu(a->type)), name);

pkt.h.answers += cpu_to_be16(1);
return true;
}

static void dns_question_set_multicast(struct dns_question *q, bool val)
Expand Down
2 changes: 1 addition & 1 deletion dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern int cfg_no_subnet;

void dns_packet_init(void);
bool dns_packet_question(const char *name, int type);
void dns_packet_answer(const char *name, int type, const uint8_t *rdata, uint16_t rdlength, int ttl);
bool dns_packet_answer(const char *name, int type, const uint8_t *rdata, uint16_t rdlength, int ttl);
void dns_packet_send(struct interface *iface, struct sockaddr *to, bool query, int multicast);

void dns_query(const char *name, uint16_t type);
Expand Down