gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13164 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r13164 - gnunet/src/vpn
Date: Tue, 5 Oct 2010 20:20:17 +0200

Author: toelke
Date: 2010-10-05 20:20:17 +0200 (Tue, 05 Oct 2010)
New Revision: 13164

Added:
   gnunet/src/vpn/gnunet-dns-parser.c
   gnunet/src/vpn/gnunet-dns-parser.h
Modified:
   gnunet/src/vpn/Makefile.am
   gnunet/src/vpn/gnunet-vpn-pretty-print.c
Log:
pull a function I will need for service-dns out of pretty-print

Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am  2010-10-05 18:20:16 UTC (rev 13163)
+++ gnunet/src/vpn/Makefile.am  2010-10-05 18:20:17 UTC (rev 13164)
@@ -35,7 +35,8 @@
 
 gnunet_daemon_vpn_SOURCES = \
  gnunet-daemon-vpn.c \
- gnunet-vpn-pretty-print.c
+ gnunet-vpn-pretty-print.c \
+ gnunet-dns-parser.c
 gnunet_daemon_vpn_LDADD = \
   $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -44,7 +45,8 @@
 
 gnunet_service_dns_SOURCES = \
  gnunet-service-dns.c \
- gnunet-vpn-pretty-print.c
+ gnunet-vpn-pretty-print.c \
+ gnunet-dns-parser.c
 gnunet_service_dns_LDADD = \
   $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \

Added: gnunet/src/vpn/gnunet-dns-parser.c
===================================================================
--- gnunet/src/vpn/gnunet-dns-parser.c                          (rev 0)
+++ gnunet/src/vpn/gnunet-dns-parser.c  2010-10-05 18:20:17 UTC (rev 13164)
@@ -0,0 +1,25 @@
+#include "platform.h"
+#include "gnunet-dns-parser.h"
+
+unsigned int parse_dns_name(unsigned char* d, const unsigned char* src, 
unsigned short idx) {/*{{{*/
+       unsigned char* dest = d;
+
+       int len = src[idx++];
+       while (len != 0) {
+               if (len & 0xC0) { /* Compressed name, offset in this and the 
next octet */
+                       unsigned short offset = ((len & 0x3F) << 8) | 
src[idx++];
+                       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 */
+                       return idx;
+               }
+               memcpy(dest, src+idx, len);
+               idx += len;
+               dest += len;
+               *dest = '.';
+               dest++;
+               len = src[idx++];
+       };
+       *dest = 0;
+
+       return idx;
+}
+/*}}}*/

Added: gnunet/src/vpn/gnunet-dns-parser.h
===================================================================
--- gnunet/src/vpn/gnunet-dns-parser.h                          (rev 0)
+++ gnunet/src/vpn/gnunet-dns-parser.h  2010-10-05 18:20:17 UTC (rev 13164)
@@ -0,0 +1,10 @@
+#ifndef _GNVPN_DNSP_H_
+#define _GNVPN_DNSP_H_
+
+/**
+ * Parses the dns-name pointed to by src+idx returning idx so, that src+idx 
points
+ * to the first unused char.
+ */
+unsigned int parse_dns_name(unsigned char* dest, const unsigned char* src, 
unsigned short idx);
+
+#endif

Modified: gnunet/src/vpn/gnunet-vpn-pretty-print.c
===================================================================
--- gnunet/src/vpn/gnunet-vpn-pretty-print.c    2010-10-05 18:20:16 UTC (rev 
13163)
+++ gnunet/src/vpn/gnunet-vpn-pretty-print.c    2010-10-05 18:20:17 UTC (rev 
13164)
@@ -9,6 +9,7 @@
 #endif
 
 #include "gnunet-vpn-packet.h"
+#include "gnunet-dns-parser.h"
 
 static char* pretty = /*{{{*/
 /*     0       1         2         3         4        5          6
@@ -245,7 +246,7 @@
 
 }}}
 
-static char* dns_classes(short class) {{{
+static char* dns_classes(short class) { /* {{{ */
        static char* classes[] = { /*{{{*/
                "",
                "IN", // 1 the Internet
@@ -256,28 +257,6 @@
 
        if (class <= 4) return classes[class];
        return 0;
-}}}
-
-unsigned int parse_dns_name(unsigned char* d, const unsigned char* src, 
unsigned short idx) {/*{{{*/
-       unsigned char* dest = d;
-
-       int len = src[idx++];
-       while (len != 0) {
-               if (len & 0xC0) { /* Compressed name, offset in this and the 
next octet */
-                       unsigned short offset = ((len & 0x3F) << 8) | 
src[idx++];
-                       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 */
-                       return idx;
-               }
-               memcpy(dest, src+idx, len);
-               idx += len;
-               dest += len;
-               *dest = '.';
-               dest++;
-               len = src[idx++];
-       };
-       *dest = 0;
-
-       return idx;
 }
 /*}}}*/
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]