]> git.meshlink.io Git - catta/blob - dns-test.c
* improve dns.c testing program
[catta] / dns-test.c
1 #include "dns.h"
2 #include "util.h"
3
4 int main(int argc, char *argv[]) {
5     gchar t[256], *a, *b, *c, *d;
6     flxDnsPacket *p;
7
8     p = flx_dns_packet_new(8000);
9
10     flx_dns_packet_append_name(p, a = "hello.hello.hello.de.");
11     flx_dns_packet_append_name(p, b = "this is a test.hello.de."); 
12     flx_dns_packet_append_name(p, c = "this\\.is\\.a\\.test\\.with\\.dots.hello.de."); 
13     flx_dns_packet_append_name(p, d = "this\\\\is another\\ \\test.hello.de."); 
14
15     flx_hexdump(FLX_DNS_PACKET_DATA(p), p->size);
16
17     flx_dns_packet_consume_name(p, t, sizeof(t));
18     g_message(">%s<", t);
19     g_assert(flx_domain_equal(a, t));
20     
21     flx_dns_packet_consume_name(p, t, sizeof(t));
22     g_message(">%s<", t);
23     g_assert(flx_domain_equal(b, t));
24
25     flx_dns_packet_consume_name(p, t, sizeof(t));
26     g_message(">%s<", t);
27     g_assert(flx_domain_equal(c, t));
28
29     flx_dns_packet_consume_name(p, t, sizeof(t));
30     g_message(">%s<", t);
31     g_assert(flx_domain_equal(d, t));
32     
33     flx_dns_packet_free(p);
34     return 0;
35 }