#include "util.h"
#include "dns.h"
-char *rdata_buffer;
-static char *name_buffer;
+char rdata_buffer[MAX_DATA_LEN + 1];
+static char name_buffer[MAX_NAME_LEN + 1];
const char*
dns_type_string(uint16_t type)
return name_buffer;
}
-
-int
-dns_init(void)
-{
- name_buffer = malloc(MAX_NAME_LEN + 1);
- rdata_buffer = malloc(MAX_DATA_LEN + 1);
-
- if (!name_buffer || !rdata_buffer)
- return -1;
-
- memset(name_buffer, 0, MAX_NAME_LEN + 1);
- memset(rdata_buffer, 0, MAX_NAME_LEN + 1);
-
- return 0;
-}
-
-void
-dns_cleanup(void)
-{
- free(name_buffer);
- free(rdata_buffer);
-}
uint16_t class;
} __attribute__((packed, aligned(2)));
-extern char *rdata_buffer;
+extern char rdata_buffer[MAX_DATA_LEN + 1];
-extern int dns_init(void);
-extern void dns_cleanup(void);
extern void dns_send_question(struct uloop_fd *u, char *question, int type);
extern void dns_init_answer(void);
extern void dns_add_answer(int type, uint8_t *rdata, uint16_t rdlength);
fprintf(stderr, "interface %s has ip %s and index %d\n", iface_name, iface_ip, iface_index);
signal_setup();
- if (dns_init())
- return -1;
-
if (cache_init())
return -1;
uloop_run();
uloop_done();
- dns_cleanup();
cache_cleanup();
service_cleanup();