aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-dns-parser.c
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2010-10-05 18:20:17 +0000
committerPhilipp Tölke <toelke@in.tum.de>2010-10-05 18:20:17 +0000
commit1ec9a4ce4e00da8e877d6af343b7fed346765392 (patch)
tree17742c43375ff1b4a83b36cf27afa67a0b7902b0 /src/vpn/gnunet-dns-parser.c
parent81f94aa0f1209d5643a1dba9f3ce99b164ce2df5 (diff)
downloadgnunet-1ec9a4ce4e00da8e877d6af343b7fed346765392.tar.gz
gnunet-1ec9a4ce4e00da8e877d6af343b7fed346765392.zip
pull a function I will need for service-dns out of pretty-print
Diffstat (limited to 'src/vpn/gnunet-dns-parser.c')
-rw-r--r--src/vpn/gnunet-dns-parser.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/vpn/gnunet-dns-parser.c b/src/vpn/gnunet-dns-parser.c
new file mode 100644
index 000000000..3425e78f6
--- /dev/null
+++ b/src/vpn/gnunet-dns-parser.c
@@ -0,0 +1,25 @@
1#include "platform.h"
2#include "gnunet-dns-parser.h"
3
4unsigned int parse_dns_name(unsigned char* d, const unsigned char* src, unsigned short idx) {/*{{{*/
5 unsigned char* dest = d;
6
7 int len = src[idx++];
8 while (len != 0) {
9 if (len & 0xC0) { /* Compressed name, offset in this and the next octet */
10 unsigned short offset = ((len & 0x3F) << 8) | src[idx++];
11 parse_dns_name(dest, src, offset - 12); /* 12 for the Header of the DNS-Packet, idx starts at 0 which is 12 bytes from the start of the packet */
12 return idx;
13 }
14 memcpy(dest, src+idx, len);
15 idx += len;
16 dest += len;
17 *dest = '.';
18 dest++;
19 len = src[idx++];
20 };
21 *dest = 0;
22
23 return idx;
24}
25/*}}}*/