From 131c43b2b18b12e52ff045e51025706802cbd2e2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 1 Jan 2012 22:49:53 +0000 Subject: -moving DNS structs to gnunet-dns-parser.h --- src/vpn/gnunet-dns-parser.h | 81 ++++++++++++++++++++++++++++++++++++++++++++- src/vpn/gnunet-vpn-packet.h | 75 +---------------------------------------- 2 files changed, 81 insertions(+), 75 deletions(-) diff --git a/src/vpn/gnunet-dns-parser.h b/src/vpn/gnunet-dns-parser.h index b5cc7e1e8..a9ed5b3b2 100644 --- a/src/vpn/gnunet-dns-parser.h +++ b/src/vpn/gnunet-dns-parser.h @@ -2,7 +2,86 @@ #define _GNVPN_DNSP_H_ #include "platform.h" -#include "gnunet-vpn-packet.h" +#include "gnunet_common.h" + +// DNS-Stuff +GNUNET_NETWORK_STRUCT_BEGIN + +struct dns_static +{ + uint16_t id GNUNET_PACKED; + + unsigned rd:1 GNUNET_PACKED; // recursion desired (client -> server) + unsigned tc:1 GNUNET_PACKED; // message is truncated + unsigned aa:1 GNUNET_PACKED; // authoritative answer + unsigned op:4 GNUNET_PACKED; // query:0, inverse q.:1, status: 2 + unsigned qr:1 GNUNET_PACKED; // query:0, response:1 + + unsigned rcode:4 GNUNET_PACKED; // 0 No error + // 1 Format error + // 2 Server failure + // 3 Name Error + // 4 Not Implemented + // 5 Refused + unsigned z:3 GNUNET_PACKED; // reserved + unsigned ra:1 GNUNET_PACKED; // recursion available (server -> client) + + uint16_t qdcount GNUNET_PACKED; // number of questions + uint16_t ancount GNUNET_PACKED; // number of answers + uint16_t nscount GNUNET_PACKED; // number of authority-records + uint16_t arcount GNUNET_PACKED; // number of additional records +}; +GNUNET_NETWORK_STRUCT_END + +struct dns_pkt +{ + struct dns_static s; + unsigned char data[1]; +}; + +struct dns_pkt_parsed +{ + struct dns_static s; + struct dns_query **queries; + struct dns_record **answers; + struct dns_record **nameservers; + struct dns_record **additional; +}; + +struct dns_query_line +{ + unsigned short type; + unsigned short class; +}; + +struct dns_query +{ + char *name; + unsigned char namelen; + unsigned short qtype; + unsigned short qclass; +}; + +struct dns_record_line +{ + unsigned short type; + unsigned short class; + unsigned int ttl; + unsigned short data_len; + unsigned char data; +}; + +struct dns_record +{ + char *name; + unsigned char namelen; + unsigned short type; + unsigned short class; + unsigned int ttl; + unsigned short data_len; + unsigned char *data; +}; + struct dns_pkt_parsed * parse_dns_packet (struct dns_pkt *pkt); diff --git a/src/vpn/gnunet-vpn-packet.h b/src/vpn/gnunet-vpn-packet.h index 9cbbf1bb2..19b2c8d7b 100644 --- a/src/vpn/gnunet-vpn-packet.h +++ b/src/vpn/gnunet-vpn-packet.h @@ -3,6 +3,7 @@ #include "platform.h" #include "gnunet_common.h" +#include "gnunet-dns-parser.h" GNUNET_NETWORK_STRUCT_BEGIN @@ -76,82 +77,8 @@ struct icmp_hdr unsigned code:8 GNUNET_PACKED; unsigned chks:16 GNUNET_PACKED; }; - -// DNS-Stuff -struct dns_static -{ - uint16_t id GNUNET_PACKED; - - unsigned rd:1 GNUNET_PACKED; // recursion desired (client -> server) - unsigned tc:1 GNUNET_PACKED; // message is truncated - unsigned aa:1 GNUNET_PACKED; // authoritative answer - unsigned op:4 GNUNET_PACKED; // query:0, inverse q.:1, status: 2 - unsigned qr:1 GNUNET_PACKED; // query:0, response:1 - - unsigned rcode:4 GNUNET_PACKED; // 0 No error - // 1 Format error - // 2 Server failure - // 3 Name Error - // 4 Not Implemented - // 5 Refused - unsigned z:3 GNUNET_PACKED; // reserved - unsigned ra:1 GNUNET_PACKED; // recursion available (server -> client) - - uint16_t qdcount GNUNET_PACKED; // number of questions - uint16_t ancount GNUNET_PACKED; // number of answers - uint16_t nscount GNUNET_PACKED; // number of authority-records - uint16_t arcount GNUNET_PACKED; // number of additional records -}; GNUNET_NETWORK_STRUCT_END -struct dns_pkt -{ - struct dns_static s; - unsigned char data[1]; -}; - -struct dns_pkt_parsed -{ - struct dns_static s; - struct dns_query **queries; - struct dns_record **answers; - struct dns_record **nameservers; - struct dns_record **additional; -}; - -struct dns_query_line -{ - unsigned short type; - unsigned short class; -}; - -struct dns_query -{ - char *name; - unsigned char namelen; - unsigned short qtype; - unsigned short qclass; -}; - -struct dns_record_line -{ - unsigned short type; - unsigned short class; - unsigned int ttl; - unsigned short data_len; - unsigned char data; -}; - -struct dns_record -{ - char *name; - unsigned char namelen; - unsigned short type; - unsigned short class; - unsigned int ttl; - unsigned short data_len; - unsigned char *data; -}; struct udp_dns { -- cgit v1.2.3