Commit Diff
Diff:
834040613b5f5dd812d16af16dbfcc47eae692e6
181a0b3fbd22dff2c60a3218a39d7ea9752cd38b
Commit:
181a0b3fbd22dff2c60a3218a39d7ea9752cd38b
Tree:
c6b0590aaf7ca9a0fe64a698d3e4328b70abc943
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Wed Jul 6 05:16:52 2016 UTC
Message:
* part 2 of moving delphinusdnsd to its own subdir
blob - 069f887c87fa33c921eca998440be96262ebf98a
blob + 2eed5abc2f45be4462f9923aa81ddf4805edd4d2
--- Makefile.openbsd
+++ Makefile.openbsd
@@ -1,17 +1,6 @@
-PROG=delphinusdnsd
+.include <bsd.own.mk>
-SRCS=main.c parse.y reply.c additional.c region.c log.c axfr.c filter.c ratelimit.c whitelist.c base64.c dnssec.c
+SUBDIR= delphinusdnsd
-#CFLAGS= -DDEBUG -g -Wall
-CFLAGS= -Wall -g -I/usr/local/include/db4
-LDFLAGS= -Wall -g -L/usr/local/lib/db4
-LDADD= -lcrypto -lssl -ldb
+.include <bsd.subdir.mk>
-OBJDIR=.
-BINDIR=/usr/local/sbin
-MANDIR=/usr/local/man/man
-
-MAN= delphinusdnsd.8
-MAN+= delphinusdns.conf.5
-
-.include <bsd.prog.mk>
blob - /dev/null
blob + b7e9e28132d6472af905f688eaccf2b82158daf8 (mode 644)
--- /dev/null
+++ ddd-db.h
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2005-2015 Peter J. Philipp
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef _DB_H
+#define _DB_H
+
+#define CONFFILE "/etc/delphinusdns.conf"
+#define DEFAULT_SOCKET 64
+
+#define ERR_DROP 0x1
+#define ERR_NXDOMAIN 0x2
+#define ERR_NOERROR 0x4
+#define ERR_REFUSED 0x8
+
+#define RECORD_COUNT 20
+#define NEGATIVE_CACHE_TIME 600 /* DNS & Bind 3rd edition page 35 */
+
+#define INTERNAL_TYPE_SOA 0
+#define INTERNAL_TYPE_A 1
+#define INTERNAL_TYPE_AAAA 2
+#define INTERNAL_TYPE_MX 3
+#define INTERNAL_TYPE_NS 4
+#define INTERNAL_TYPE_CNAME 5
+#define INTERNAL_TYPE_PTR 6
+#define INTERNAL_TYPE_TXT 7
+#define INTERNAL_TYPE_SPF 8
+#define INTERNAL_TYPE_SRV 9
+#define INTERNAL_TYPE_SSHFP 10
+#define INTERNAL_TYPE_NAPTR 11
+#define INTERNAL_TYPE_DNSKEY 12
+#define INTERNAL_TYPE_DS 13
+#define INTERNAL_TYPE_NSEC 14
+#define INTERNAL_TYPE_RRSIG 15
+#define INTERNAL_TYPE_NSEC3 16
+#define INTERNAL_TYPE_NSEC3PARAM 17
+#define INTERNAL_TYPE_TLSA 18
+#define INTERNAL_TYPE_MAX 19
+
+/* db stuff */
+
+struct dnskey {
+ u_int16_t flags;
+#define DNSKEY_ZONE_KEY (1 << 7)
+#define DNSKEY_SECURE_ENTRY (1 << 15)
+ u_int8_t protocol; /* must be 3 */
+ u_int8_t algorithm; /* would be 5, RFC 3110 */
+ char public_key[4096];
+ u_int16_t publickey_len;
+} __attribute__((packed));
+
+
+struct rrsig {
+ u_int16_t type_covered;
+ u_int8_t algorithm; /* usually 5, RFC3110 */
+ u_int8_t labels;
+ u_int32_t original_ttl;
+ u_int32_t signature_expiration;
+ u_int32_t signature_inception;
+ u_int16_t key_tag;
+ char signers_name[DNS_MAXNAME];
+ u_int8_t signame_len;
+ char signature[4096];
+ u_int16_t signature_len;
+} __attribute__((packed));
+
+struct nsec {
+ char next_domain_name[DNS_MAXNAME];
+ u_int8_t ndn_len; /* next domain name length */
+ char bitmap[8192];
+ u_int16_t bitmap_len;
+} __attribute__((packed));
+
+struct nsec3 {
+ u_int8_t algorithm;
+ u_int8_t flags;
+ u_int16_t iterations;
+ u_int8_t saltlen;
+ char salt[256];
+ char next[DNS_MAXNAME];
+ u_int8_t nextlen; /* next domain name length */
+ char bitmap[8192];
+ u_int16_t bitmap_len;
+} __attribute__((packed));
+
+struct nsec3param {
+ u_int8_t algorithm;
+ u_int8_t flags;
+ u_int16_t iterations;
+ u_int8_t saltlen;
+ char salt[256];
+} __attribute__((packed));
+
+struct ds {
+ u_int16_t key_tag;
+ u_int8_t algorithm;
+ u_int8_t digest_type;
+ char digest[4096];
+ u_int16_t digestlen;
+} __attribute__((packed));
+
+
+struct soa {
+ char nsserver[DNS_MAXNAME];
+ u_int8_t nsserver_len;
+ char responsible_person[DNS_MAXNAME];
+ u_int8_t rp_len;
+ u_int32_t serial;
+ u_int32_t refresh;
+ u_int32_t retry;
+ u_int32_t expire;
+ u_int32_t minttl;
+} __attribute__((packed));
+
+struct smx {
+ u_int16_t preference; /* MX preference */
+ char exchange[DNS_MAXNAME]; /* name of exchange server */
+ int exchangelen; /* length of exchange server name */
+} __attribute__((packed));
+
+struct ns {
+ char nsserver[DNS_MAXNAME]; /* NS name */
+ int nslen; /* length of NS */
+} __attribute__((packed));
+
+struct srv {
+ u_int16_t priority; /* SRV 16 bit priority */
+ u_int16_t weight; /* 16 bit weight */
+ u_int16_t port; /* 16 bit port */
+ char target[DNS_MAXNAME]; /* SRV target name */
+ int targetlen; /* SRV target name length */
+} __attribute__((packed));
+
+struct sshfp {
+ u_int8_t algorithm; /* SSHFP algorithm */
+ u_int8_t fptype; /* SSHFP fingerprint type */
+ char fingerprint[DNS_MAXNAME]; /* fingerprint */
+ int fplen; /* fingerprint length */
+} __attribute__((packed));
+
+struct tlsa {
+ u_int8_t usage; /* TLSA usage */
+ u_int8_t selector; /* TLSA selector */
+ u_int8_t matchtype; /* TLSA matching type */
+ char data[DNS_MAXNAME]; /* TLSA data */
+ int datalen; /* data length */
+} __attribute__((packed));
+
+struct naptr {
+ u_int16_t order; /* NAPTR 16 bit order */
+ u_int16_t preference; /* 16 bit preference */
+ char flags[DNS_MAXNAME]; /* flags 255 bytes */
+ int flagslen; /* flags length */
+ char services[DNS_MAXNAME]; /* services */
+ int serviceslen; /* services length */
+ char regexp[DNS_MAXNAME]; /* regexp */
+ int regexplen; /* regexp len */
+ char replacement[DNS_MAXNAME]; /* replacement this is a domain */
+ int replacementlen;
+} __attribute__((packed));
+
+struct domain {
+ u_int16_t type;
+ u_int32_t len;
+ char zone[DNS_MAXNAME]; /* name of zone in dns name format */
+ int zonelen; /* length of zone, above */
+ char zonename[DNS_MAXNAME + 1]; /* name of zone in human readable */
+ u_int64_t flags; /* flags of zone */
+#define DOMAIN_HAVE_A 0x1
+#define DOMAIN_HAVE_SOA 0x2
+#define DOMAIN_HAVE_CNAME 0x4
+#define DOMAIN_HAVE_PTR 0x8
+#define DOMAIN_HAVE_MX 0x10
+#define DOMAIN_HAVE_AAAA 0x20
+#define DOMAIN_HAVE_NS 0x40
+#define DOMAIN_HAVE_TXT 0x80
+#define DOMAIN_HAVE_SRV 0x100
+#define DOMAIN_HAVE_SPF 0x200
+#define DOMAIN_HAVE_SSHFP 0x400
+#define DOMAIN_HAVE_NAPTR 0x800
+#define DOMAIN_HAVE_DNSKEY 0x1000
+#define DOMAIN_HAVE_DS 0x2000
+#define DOMAIN_HAVE_NSEC 0x4000
+#define DOMAIN_HAVE_RRSIG 0x8000
+#define DOMAIN_HAVE_NSEC3 0x10000
+#define DOMAIN_HAVE_NSEC3PARAM 0x20000
+#define DOMAIN_HAVE_TLSA 0x40000
+ u_int32_t ttl[INTERNAL_TYPE_MAX]; /* time to lives */
+ time_t created; /* time created, for dynamic zones */
+} __attribute__((packed));
+
+struct domain_generic {
+ u_int16_t type;
+ u_int32_t len;
+} __attribute__((packed));
+
+struct domain_soa {
+ u_int16_t type;
+ u_int32_t len;
+ struct soa soa; /* start of authority */
+} __attribute__((packed));
+
+struct domain_rrsig {
+ u_int16_t type;
+ u_int32_t len;
+ struct rrsig rrsig[INTERNAL_TYPE_MAX]; /* rrsig RR */
+ struct rrsig rrsig_dnskey[RECORD_COUNT];/* hack around dnskeys */
+ int rrsig_dnskey_count; /* RRSIG count */
+ struct rrsig rrsig_ds[RECORD_COUNT]; /* hack around ds */
+ int rrsig_ds_count;
+} __attribute__((packed));
+
+
+struct domain_a {
+ u_int16_t type;
+ u_int32_t len;
+ in_addr_t a[RECORD_COUNT]; /* IP addresses */
+ u_int8_t region[RECORD_COUNT]; /* region of IP address */
+ int a_ptr; /* pointer to last used address */
+ int a_count; /* IP address count (max 10) */
+} __attribute__((packed));
+
+struct domain_aaaa {
+ u_int16_t type;
+ u_int32_t len;
+ struct in6_addr aaaa[RECORD_COUNT]; /* IPv6 addresses */
+ int aaaa_count; /* IPv6 address count (max 10) */
+ int aaaa_ptr; /* pointer to last used IPv6 address */
+} __attribute__((packed));
+
+struct domain_mx {
+ u_int16_t type;
+ u_int32_t len;
+ struct smx mx[RECORD_COUNT]; /* MX addresses */
+ int mx_count; /* MX address count, max 10 */
+ int mx_ptr; /* pointer to last used MX adddress */
+} __attribute__((packed));
+
+struct domain_ns {
+ u_int16_t type;
+ u_int32_t len;
+ struct ns ns[RECORD_COUNT]; /* NS resource records (max 10) */
+ int ns_count; /* count of NS records, (max 10) */
+ int ns_ptr; /* pointer to last used NS address */
+ int ns_type; /* set if it's a delegation */
+#define NS_TYPE_DELEGATE 0x1
+#define NS_TYPE_HINT 0x2
+} __attribute__((packed));
+
+struct domain_cname {
+ u_int16_t type;
+ u_int32_t len;
+ char cname[DNS_MAXNAME]; /* CNAME RR */
+ int cnamelen; /* len of CNAME */
+} __attribute__((packed));
+
+struct domain_ptr {
+ u_int16_t type;
+ u_int32_t len;
+ char ptr[DNS_MAXNAME]; /* PTR RR */
+ int ptrlen; /* len of PTR */
+} __attribute__((packed));
+
+struct domain_txt {
+ u_int16_t type;
+ u_int32_t len;
+ char txt[DNS_MAXNAME]; /* TXT string */
+ int txtlen; /* len of TXT */
+} __attribute__((packed));
+
+struct domain_spf {
+ u_int16_t type;
+ u_int32_t len;
+ char spf[DNS_MAXNAME]; /* SPF string */
+ int spflen; /* len of SPF */
+} __attribute__((packed));
+
+struct domain_srv {
+ u_int16_t type;
+ u_int32_t len;
+ struct srv srv[RECORD_COUNT]; /* SRV resource record */
+ int srv_count; /* count of SRV RR */
+} __attribute__((packed));
+
+struct domain_sshfp {
+ u_int16_t type;
+ u_int32_t len;
+ struct sshfp sshfp[RECORD_COUNT]; /* SSHFP resource record */
+ int sshfp_count; /* SSHFP RR count */
+} __attribute__((packed));
+
+struct domain_tlsa {
+ u_int16_t type;
+ u_int32_t len;
+ struct tlsa tlsa[RECORD_COUNT]; /* TLSA resource record */
+ int tlsa_count; /* TLSA RR count */
+} __attribute__((packed));
+
+struct domain_naptr {
+ u_int16_t type;
+ u_int32_t len;
+ struct naptr naptr[RECORD_COUNT]; /* NAPTR RR, eek 20K! */
+ int naptr_count;
+} __attribute__((packed));
+
+struct domain_dnskey {
+ u_int16_t type;
+ u_int32_t len;
+ struct dnskey dnskey[RECORD_COUNT]; /* DNSKEY RR */
+ int dnskey_count; /* count of DNSKEY */
+} __attribute__((packed));
+
+struct domain_nsec {
+ u_int16_t type;
+ u_int32_t len;
+ struct nsec nsec; /* NSEC RR */
+} __attribute__((packed));
+
+struct domain_nsec3 {
+ u_int16_t type;
+ u_int32_t len;
+ struct nsec3 nsec3; /* NSEC3 RR */
+} __attribute__((packed));
+
+struct domain_nsec3param {
+ u_int16_t type;
+ u_int32_t len;
+ struct nsec3param nsec3param; /* NSEC3PARAM RR */
+} __attribute__((packed));
+
+struct domain_ds {
+ u_int16_t type;
+ u_int32_t len;
+ struct ds ds[RECORD_COUNT]; /* DS RR */
+ int ds_count; /* count of DS */
+} __attribute__((packed));
+
+
+struct sreply {
+ int so; /* socket */
+ char *buf; /* question packet */
+ int len; /* question packet length */
+ struct question *q; /* struct question */
+ struct sockaddr *sa; /* struct sockaddr of question */
+ int salen; /* length of struct sockaddr */
+ struct domain *sd1; /* first resolved domain */
+ struct domain *sd2; /* CNAME to second resolved domain */
+ u_int8_t region; /* region of question */
+ int istcp; /* when set it's tcp */
+ int wildcard; /* wildcarding boolean */
+ struct recurses *sr; /* recurses struct for raw sockets */
+ char *replybuf; /* reply buffer */
+};
+
+struct srecurseheader {
+ int af; /* address family */
+ int proto; /* protocol UDP/TCP */
+ struct sockaddr_storage source; /* source + port */
+ struct sockaddr_storage dest; /* dest + port */
+ int len; /* length of question */
+ char buf[512]; /* question buffer */
+};
+
+
+SLIST_HEAD(listhead2, recurses) recurseshead;
+
+struct recurses {
+ char query[512]; /* the query we received */
+ int len; /* length of query */
+
+ int isfake; /* received or faked */
+ int launched; /* is launched */
+ int replied; /* we replied to this question */
+ int packetcount; /* packet count of requests */
+ int af; /* address family */
+ int proto; /* protocol UDP/TCP */
+ struct sockaddr_storage source; /* source + port */
+ struct sockaddr_storage dest; /* dest + port */
+
+ time_t received; /* received request time */
+ time_t sent_last_query; /* the last time we did a lookup */
+
+ char upperlower[32]; /* uppercase / lowercase bitmap */
+ int so; /* the socket we did a lookup with */
+ u_short port; /* port used on outgoing */
+ u_int16_t id; /* last id used */
+
+ /* the below get loaded from the database upon each lookup */
+ in_addr_t a[RECORD_COUNT]; /* IPv4 addresses of nameservers */
+ int a_count; /* IPv4 address count */
+ int a_ptr; /* pointer to last used address */
+ struct in6_addr aaaa[RECORD_COUNT]; /* IPv6 addresses of nameservers */
+ int aaaa_count; /* IPv6 address count */
+ int aaaa_ptr; /* pointer to last used IPv6 address */
+
+ /* the below is our indicator which part of the lookup we're at */
+
+ u_char *lookrecord; /* what zone lookup is it from */
+ int indicator; /* indicator of ns lookup */
+ int authoritative; /* last reply was authoritative, type */
+ int hascallback; /* some request has callback don't remove */
+
+ struct question *question; /* question struct */
+ SLIST_ENTRY(recurses) recurses_entry;
+ struct recurses *callback; /* callback */
+} *sr, *sr1, *sr2;
+
+struct logging {
+ int active;
+ char *hostname;
+ int bind;
+ char *loghost;
+ struct sockaddr_storage loghost2;
+ char *logport;
+ u_int16_t logport2;
+ char *logpasswd;
+};
+
+struct cfg {
+ int udp[DEFAULT_SOCKET]; /* udp sockets */
+ int tcp[DEFAULT_SOCKET]; /* tcp socket */
+ int axfr[DEFAULT_SOCKET]; /* axfr udp socket */
+ char *ident[DEFAULT_SOCKET]; /* identification of interface */
+ int recurse; /* recurse socket */
+ int log; /* logging socket */
+ int sockcount; /* set sockets */
+ DB *db; /* database */
+};
+
+
+int parse_file(DB *db, char *);
+DB * opendatabase(DB *);
+
+
+#endif /* _DB_H */
blob - /dev/null
blob + da7f28e7d109e9a5abe44e844a8717da35498e48 (mode 644)
--- /dev/null
+++ ddd-dns.h
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2002-2015 Peter J. Philipp
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef _DNS_H
+#define _DNS_H
+
+
+/* RFC 1035 - page 26 */
+
+struct dns_header {
+ u_int16_t id; /* ID of header */
+ u_int16_t query;
+ u_int16_t question; /* # of question entries */
+ u_int16_t answer; /* # of answer RR's */
+ u_int16_t nsrr; /* # of NS RR's */
+ u_int16_t additional; /* # additional RR's */
+};
+
+struct dns_hints {
+ int proto;
+ u_int16_t id;
+ u_int16_t query;
+ u_int16_t question;
+ u_int16_t answer;
+ u_int16_t nsrr;
+ u_int16_t additional;
+};
+
+/*
+ * resource record structure
+ * RFC 1035 - page 9
+ */
+
+struct dns_rr {
+ char *name; /* name of zone */
+ char *question; /* pointer to question */
+ u_int16_t type; /* type of RR */
+ u_int16_t class; /* class of reply */
+ u_int32_t ttl; /* ttl of record */
+ u_int16_t rdlen; /* length of record */
+ char *rdata; /* data of record */
+};
+
+/*
+ * EDNS0 OPT RR, based on dns_rr
+ * RFC 6891 - page 7
+ */
+
+struct dns_optrr {
+ char name[1]; /* always 0 */
+ u_int16_t type; /* must be 41 */
+ u_int16_t class; /* UDP payload size (4096) */
+ u_int32_t ttl; /* extended RCODE */
+ u_int16_t rdlen; /* length of all RDATA */
+ char rdata[0]; /* attribute, value pairs */
+}__attribute__((packed));
+
+/* RFC 1035 - page 28 */
+struct dns_question_hdr {
+ char *name;
+ u_int namelen;
+ u_int16_t qtype;
+ u_int16_t qclass;
+};
+
+
+
+/*
+ * flags RFC 1035, page 26
+ */
+
+#define DNS_REPLY 0x8000 /* if set response if not set query */
+#define DNS_NOTIFY 0x2000 /* a NOTIFY query RFC 1996 */
+#define DNS_SREQ 0x1000 /* if set a server status request (STATUS) */
+#define DNS_INV 0x800 /* if set an inverse query */
+#define DNS_AUTH 0x400 /* Authoritative Answer (AA) in replies */
+#define DNS_TRUNC 0x200 /* Truncated (TC) */
+#define DNS_RECURSE 0x100 /* if set Recursion Desired (RD) */
+#define DNS_RECAVAIL 0x80 /* if set Recursion Available (RA) */
+#define DNS_BADTIME 0x12 /* RCODE (18) BADTIME RFC 2845 p. 3 */
+#define DNS_BADKEY 0x11 /* RCODE (17) BADKEY RFC 2845 p. 3 */
+#define DNS_BADSIG 0x10 /* RCODE (16) BADSIG RFC 2845 p. 3 */
+#define DNS_BADVERS 0x10 /* RCODE (16) BADVERS RFC 2671 p. 6 */
+#define DNS_REFUSED 0x5 /* RCODE - Refused */
+#define DNS_NOTIMPL 0x4 /* RCODE - Not Implemented */
+#define DNS_NAMEERR 0x3 /* RCODE - Name Error, NXDOMAIN */
+#define DNS_SERVFAIL 0x2 /* RCODE - Server Failure */
+#define DNS_FORMATERR 0x1 /* RCODE - Format Error */
+#define DNS_NOERR 0x0 /* RCODE - No error */
+
+/*
+ * macros to set flags (must be converted to network byte order after)
+ */
+
+#define SET_DNS_REPLY(x) ((x)->query |= (DNS_REPLY))
+#define SET_DNS_QUERY(x) ((x)->query &= ~(DNS_REPLY))
+#define SET_DNS_NOTIFY(x) ((x)->query |= (DNS_NOTIFY))
+#define SET_DNS_STATUS_REQ(x) ((x)->query |= (DNS_SREQ))
+#define SET_DNS_INVERSE_QUERY(x) ((x)->query |= (DNS_INV))
+#define SET_DNS_AUTHORITATIVE(x) ((x)->query |= (DNS_AUTH))
+#define SET_DNS_TRUNCATION(x) ((x)->query |= (DNS_TRUNC))
+#define SET_DNS_RECURSION(x) ((x)->query |= (DNS_RECURSE))
+#define SET_DNS_RECURSION_AVAIL(x) ((x)->query |= (DNS_RECAVAIL))
+#define SET_DNS_RCODE_REFUSED(x) ((x)->query |= (DNS_REFUSED))
+#define SET_DNS_RCODE_NOTIMPL(x) ((x)->query |= (DNS_NOTIMPL))
+#define SET_DNS_RCODE_NAMEERR(x) ((x)->query |= (DNS_NAMEERR))
+#define SET_DNS_RCODE_SERVFAIL(x) ((x)->query |= (DNS_SERVFAIL))
+#define SET_DNS_RCODE_FORMATERR(x) ((x)->query |= (DNS_FORMATERR))
+#define SET_DNS_RCODE_NOERR(x) ((x)->query |= (DNS_NOERR))
+
+#define UNSET_DNS_NOTIFY(x) ((x)->query &= ~(DNS_NOTIFY))
+#define UNSET_DNS_STATUS_REQ(x) ((x)->query &= ~(DNS_SREQ))
+#define UNSET_DNS_INVERSE_QUERY(x) ((x)->query &= ~(DNS_INV))
+#define UNSET_DNS_AUTHORITATIVE(x) ((x)->query &= ~(DNS_AUTH))
+#define UNSET_DNS_TRUNCATION(x) ((x)->query &= ~(DNS_TRUNC))
+#define UNSET_DNS_RECURSION(x) ((x)->query &= ~(DNS_RECURSE))
+#define UNSET_DNS_RECURSION_AVAIL(x) ((x)->query &= ~(DNS_RECAVAIL))
+#define UNSET_DNS_RCODE_REFUSED(x) ((x)->query &= ~(DNS_REFUSED))
+#define UNSET_DNS_RCODE_NOTIMPL(x) ((x)->query &= ~(DNS_NOTIMPL))
+#define UNSET_DNS_RCODE_NAMEERR(x) ((x)->query &= ~(DNS_NAMEERR))
+#define UNSET_DNS_RCODE_SERVFAIL(x) ((x)->query &= ~(DNS_SERVFAIL))
+#define UNSET_DNS_RCODE_FORMATERR(x) ((x)->query &= ~(DNS_FORMATERR))
+#define UNSET_DNS_RCODE_NOERR(x) ((x)->query &= ~(DNS_NOERR))
+
+/* DNSSEC/EDNS0 options RFC 3225 */
+
+#define DNSSEC_OK 0x8000
+
+#define SET_DNS_ERCODE_DNSSECOK(x) ((x)->ttl |= (DNSSEC_OK))
+#define UNSET_DNS_ERCODE_DNSSECOK(x) ((x)->ttl &= ~(DNSSEC_OK))
+
+/* DNS types - RFC 1035 page 12 */
+
+#define DNS_TYPE_A 1
+#define DNS_TYPE_NS 2
+#define DNS_TYPE_CNAME 5
+#define DNS_TYPE_SOA 6
+#define DNS_TYPE_PTR 12
+#define DNS_TYPE_MX 15
+#define DNS_TYPE_TXT 16
+
+#define DNS_TYPE_SRV 33 /* RFC 2782, page 8 */
+#define DNS_TYPE_NAPTR 35 /* RFC 2915, page 3 */
+#define DNS_TYPE_OPT 41 /* RFC 6891, page 7 */
+#define DNS_TYPE_DS 43 /* RFC 4034, section 5 */
+#define DNS_TYPE_SSHFP 44 /* RFC 4255 */
+#define DNS_TYPE_RRSIG 46 /* RFC 4034, section 3 */
+#define DNS_TYPE_NSEC 47 /* RFC 4034, section 4 */
+#define DNS_TYPE_DNSKEY 48 /* RFC 4034, section 2 */
+
+#define DNS_TYPE_NSEC3 50 /* RFC 5155, section 3 */
+#define DNS_TYPE_NSEC3PARAM 51 /* RFC 5155, section 4 */
+#define DNS_TYPE_TLSA 52 /* RFC 6698, section 7.1 */
+
+#define DNS_TYPE_SPF 99 /* RFC 4408 */
+
+#define DNS_TYPE_TSIG 250 /* RFC 2845, page 3 */
+#define DNS_TYPE_IXFR 251 /* RFC 1995, page 2 */
+#define DNS_TYPE_AXFR 252 /* RFC 5936, page 10 */
+#define DNS_TYPE_ANY 255
+
+/* DNS types 0xff00 -> 0xfffe (private use) RFC 5395, page 8 */
+
+#define DNS_TYPE_BALANCE 0xfffe /* split horizon dns */
+#define DNS_TYPE_DELEGATE 0xfffd /* ns delegations */
+#define DNS_TYPE_HINT 0xfffc /* root hint */
+
+/* quad A - RFC 3596 */
+#define DNS_TYPE_AAAA 28
+
+
+/* DNS CLASSES - RFC 1035 page 13 */
+
+#define DNS_CLASS_IN 1 /* internet */
+#define DNS_CLASS_CH 3 /* chaos */
+#define DNS_CLASS_HS 4 /* hesiod */
+
+#define DNS_CLASS_ANY 255 /* any class */
+
+/* limits */
+
+#define DNS_MAXLABEL 63
+#define DNS_MAXNAME 255
+#define DNS_MAXUDP 512
+
+/* SSHFP fingerprint sizes */
+
+#define DNS_SSHFP_SIZE_SHA1 20 /* RFC 4255 */
+#define DNS_SSHFP_SIZE_SHA256 32 /* RFC 6594 */
+
+/* TLSA fingerprint sizes */
+
+#define DNS_TLSA_SIZE_SHA256 32 /* RFC 6698 */
+#define DNS_TLSA_SIZE_SHA512 64 /* RFC 6698 */
+
+struct question {
+ struct dns_question_hdr *hdr;
+ char *converted_name;
+ u_int16_t edns0len;
+ u_int8_t ednsversion;
+ int dnssecok;
+ int badvers;
+};
+
+#endif /* DNS_H */
blob - /dev/null
blob + a4032690a166804e442af0d4c42adf28ff67d569 (mode 644)
--- /dev/null
+++ ddd-include.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2005-2015 Peter J. Philipp
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef _INCLUDES_H
+#define _INCLUDES_H
+
+#include <sys/param.h>
+#include <sys/ipc.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <sys/queue.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/udp.h>
+#define _KERNEL 1
+#include <netinet/ip6.h>
+#undef _KERNEL
+
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <syslog.h>
+#include <ctype.h>
+#include <db.h>
+#include <pwd.h>
+#include <ifaddrs.h>
+#include <dirent.h>
+#include <signal.h>
+
+#ifdef __linux__
+#include <grp.h>
+#endif
+
+#ifndef NTOHS
+#include "endian.h"
+#endif
+
+#if !defined __OpenBSD__ && !defined __NetBSD__
+struct ip6_hdr_pseudo {
+ struct in6_addr ip6ph_src;
+ struct in6_addr ip6ph_dst;
+ u_int32_t ip6ph_len;
+ u_int8_t ip6ph_zero[3];
+ u_int8_t ip6ph_nxt;
+} __packed;
+#endif
+
+#endif
repomaster@centroid.eu