From: Philipp Tölke Date: Tue, 19 Oct 2010 21:16:45 +0000 (+0000) Subject: allow the service-dns to answer not only with an unchanged dns-packet, but X-Git-Tag: initial-import-from-subversion-38251~20041 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=708311b404b5d29a482db3e39f58e623fd85801d;p=oweals%2Fgnunet.git allow the service-dns to answer not only with an unchanged dns-packet, but also with other types of answer --- diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 8790ff7f3..43fe356ff 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -151,6 +151,8 @@ static void helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* t struct answer_packet_list* ans = mycls.answer_head; size_t len = ntohs(ans->pkt.hdr.size); + GNUNET_assert(ans->pkt.subtype == GNUNET_DNS_ANSWER_TYPE_IP); + size_t data_len = len - sizeof(struct answer_packet) + 1; size_t net_len = sizeof(struct ip_hdr) + sizeof(struct udp_dns) + data_len; size_t pkt_len = sizeof(struct GNUNET_MessageHeader) + sizeof(struct pkt_tun) + net_len; diff --git a/src/vpn/gnunet-service-dns-p.h b/src/vpn/gnunet-service-dns-p.h index a995c73e5..b8f570a87 100644 --- a/src/vpn/gnunet-service-dns-p.h +++ b/src/vpn/gnunet-service-dns-p.h @@ -19,15 +19,24 @@ struct query_packet_list { struct query_packet pkt; }; +enum GNUNET_DNS_ANSWER_Subtype { + /** + * Answers of this type contain a dns-packet that just has to be transmitted + */ + GNUNET_DNS_ANSWER_TYPE_IP +}; + struct answer_packet { - struct GNUNET_MessageHeader hdr; + struct GNUNET_MessageHeader hdr; + enum GNUNET_DNS_ANSWER_Subtype subtype GNUNET_PACKED; - unsigned from:32 GNUNET_PACKED; - unsigned to:32 GNUNET_PACKED; - unsigned dst_port:16 GNUNET_PACKED; + unsigned from:32 GNUNET_PACKED; + unsigned to:32 GNUNET_PACKED; + unsigned dst_port:16 GNUNET_PACKED; - unsigned char data[1]; + unsigned char data[1]; }; + struct answer_packet_list { struct answer_packet_list* next GNUNET_PACKED; struct answer_packet_list* prev GNUNET_PACKED; diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index 54b97a25c..a732739b5 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c @@ -178,6 +178,7 @@ static void read_response (void *cls, const struct GNUNET_SCHEDULER_TaskContext struct answer_packet_list* answer = GNUNET_malloc(len + 2*sizeof(struct answer_packet_list*)); answer->pkt.hdr.type = htons(GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS); answer->pkt.hdr.size = htons(len); + answer->pkt.subtype = GNUNET_DNS_ANSWER_TYPE_IP; answer->pkt.from = addr.sin_addr.s_addr; answer->pkt.to = query_states[dns->s.id].local_ip; answer->pkt.dst_port = query_states[dns->s.id].local_port;