}
void
-dns_send_question(struct uloop_fd *u, char *question, int type)
+dns_send_question(struct uloop_fd *u, const char *question, int type)
{
static struct dns_header h = {
.questions = cpu_to_be16(1),
}
void
-dns_add_answer(int type, uint8_t *rdata, uint16_t rdlength)
+dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength)
{
struct dns_reply *a = &dns_reply[dns_answer_cnt];
if (dns_answer_cnt == MAX_ANSWER)
}
void
-dns_send_answer(struct uloop_fd *u, char *answer)
+dns_send_answer(struct uloop_fd *u, const char *answer)
{
uint8_t buffer[256];
struct dns_header h = { 0 };
h.answers = __cpu_to_be16(dns_answer_cnt);
h.flags = __cpu_to_be16(0x8400);
- iov = malloc(sizeof(struct iovec) * ((dns_answer_cnt * 3) + 1));
- if (!iov)
- return;
-
+ iov = alloca(sizeof(struct iovec) * ((dns_answer_cnt * 3) + 1));
iov[0].iov_base = &h;
iov[0].iov_len = sizeof(struct dns_header);
}
static int
-scan_name(uint8_t *buffer, int len)
+scan_name(const uint8_t *buffer, int len)
{
int offset = 0;
}
char*
-dns_consume_name(uint8_t *base, int blen, uint8_t **data, int *len)
+dns_consume_name(const uint8_t *base, int blen, uint8_t **data, int *len)
{
int nlen = scan_name(*data, *len);