summaryrefslogtreecommitdiff
path: root/src/hip.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hip.c')
-rw-r--r--src/hip.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/hip.c b/src/hip.c
new file mode 100644
index 0000000..58b3041
--- /dev/null
+++ b/src/hip.c
@@ -0,0 +1,71 @@
+/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 dated June, 1991, or
+ (at your option) version 3 dated 29 June, 2007.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "dnsmasq.h"
+
+#ifdef HAVE_HIP
+
+size_t answer_hip(struct dns_header *header, char *limit, size_t qlen)
+{
+ /* Answer A or AAAA request using cached HIT */
+ return 0;
+}
+
+void hip_make_request(struct dns_header *header, size_t qlen)
+{
+ unsigned char *p = (unsigned char *)(header+1);
+
+ if (ntohs(header->qdcount) != 1 || OPCODE(header) != QUERY)
+ return; /* must be exactly one query. */
+
+ if (!extract_name(header, qlen, &p, daemon->namebuff, 1, 4))
+ return; /* bad packet */
+
+ PUTSHORT(T_HIP, p);
+}
+
+size_t hip_restore_request(struct dns_header *header, size_t qlen, int flags)
+{
+ unsigned char *p = (unsigned char *)(header+1);
+ unsigned short type = T_A;
+ size_t nn, hlen;
+ unsigned char *pheader;
+
+#ifdef HAVE_IPV6
+ if (flags & FREC_HIP_V6)
+ type = T_AAAA;
+#endif
+
+ if (ntohs(header->qdcount) != 1)
+ return 0; /* must be exactly one query. */
+
+ if (!extract_name(header, qlen, &p, daemon->namebuff, 1, 4))
+ return 0; /* bad packet */
+
+ PUTSHORT(type, p);
+
+ /* and remove answers */
+ pheader = find_pseudoheader(header, qlen, &hlen, NULL, NULL);
+ header->ancount = htons(0);
+ header->nscount = htons(0);
+ header->arcount = htons(0);
+ nn = resize_packet(header, qlen, pheader, hlen);
+
+ return nn;
+}
+
+
+#endif