Skip to content
Snippets Groups Projects
Commit 7598a9ce authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Merge remote branch 'origin/dnslib-new' into zoneparser

parents 1b38ea2e 24ee8d32
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,11 @@
#include <string.h>
#include <sys/types.h>
#include "descriptor.h"
//#include "descriptor.h"
#include "dnslib.h"
/* TODO this has to be removed - move tokens to separate file */
#include "zoneparser.h"
#include "zparser.h"
enum desclen { DNSLIB_RRTYPE_DESCRIPTORS_LENGTH = 32770 }; // used to be 101
......@@ -21,56 +25,56 @@ static dnslib_lookup_table_t dns_rrclasses[] = {
static dnslib_rrtype_descriptor_t
dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRIPTORS_LENGTH] = {
/* 0 */
{ 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ 0, 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 1 */
{ DNSLIB_RRTYPE_A, "A", 1, { DNSLIB_RDATA_WF_A }, true },
{ DNSLIB_RRTYPE_A, T_A, "A", 1, { DNSLIB_RDATA_WF_A }, true },
/* 2 */
{ DNSLIB_RRTYPE_NS, "NS", 1,
{ DNSLIB_RRTYPE_NS, T_NS, "NS", 1,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 3 */
{ DNSLIB_RRTYPE_MD, "MD", 1,
{ DNSLIB_RRTYPE_MD, T_MD, "MD", 1,
{ DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true },
/* 4 */
{ DNSLIB_RRTYPE_MF, "MF", 1,
{ DNSLIB_RRTYPE_MF, T_MF, "MF", 1,
{ DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true },
/* 5 */
{ DNSLIB_RRTYPE_CNAME, "CNAME", 1,
{ DNSLIB_RRTYPE_CNAME, T_CNAME, "CNAME", 1,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 6 */
{ DNSLIB_RRTYPE_SOA, "SOA", 7,
{ DNSLIB_RRTYPE_SOA, T_SOA, "SOA", 7,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME, DNSLIB_RDATA_WF_COMPRESSED_DNAME,
DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG,
DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG }, true },
/* 7 */
{ DNSLIB_RRTYPE_MB, "MB", 1,
{ DNSLIB_RRTYPE_MB, T_MB, "MB", 1,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 8 */
{ DNSLIB_RRTYPE_MG, "MG", 1,
{ DNSLIB_RRTYPE_MG, T_MG, "MG", 1,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 9 */
{ DNSLIB_RRTYPE_MR, "MR", 1,
{ DNSLIB_RRTYPE_MR, T_MR, "MR", 1,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 10 */
{ DNSLIB_RRTYPE_NULL, NULL, 1,
{ DNSLIB_RRTYPE_NULL, T_NULL, NULL, 1,
{ DNSLIB_RDATA_WF_BINARY }, true },
/* 11 */
{ DNSLIB_RRTYPE_WKS, "WKS", 2,
{ DNSLIB_RRTYPE_WKS, T_WKS, "WKS", 2,
{ DNSLIB_RDATA_WF_A, DNSLIB_RDATA_WF_BINARY }, true },
/* 12 */
{ DNSLIB_RRTYPE_PTR, "PTR", 1,
{ DNSLIB_RRTYPE_PTR, T_PTR, "PTR", 1,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 13 */
{ DNSLIB_RRTYPE_HINFO, "HINFO", 2,
{ DNSLIB_RRTYPE_HINFO, T_HINFO, "HINFO", 2,
{ DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, true },
/* 14 */
{ DNSLIB_RRTYPE_MINFO, "MINFO", 2,
{ DNSLIB_RRTYPE_MINFO, T_MINFO, "MINFO", 2,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME,
DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 15 */
{ DNSLIB_RRTYPE_MX, "MX", 2,
{ DNSLIB_RRTYPE_MX, T_MX, "MX", 2,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 16 */ /* This is obscure, but I guess there's no other way */
{ DNSLIB_RRTYPE_TXT, "TXT", DNSLIB_MAX_RDATA_ITEMS,
{ DNSLIB_RRTYPE_TXT, T_TXT, "TXT", DNSLIB_MAX_RDATA_ITEMS,
{ DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
......@@ -104,88 +108,89 @@ static dnslib_rrtype_descriptor_t
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, false },
/* 17 */
{ DNSLIB_RRTYPE_RP, "RP", 2,
{ DNSLIB_RRTYPE_RP, T_RP, "RP", 2,
{ DNSLIB_RDATA_WF_COMPRESSED_DNAME,
DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 18 */
{ DNSLIB_RRTYPE_AFSDB, "AFSDB", 2,
{ DNSLIB_RRTYPE_AFSDB, T_AFSDB, "AFSDB", 2,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 19 */
{ DNSLIB_RRTYPE_X25, "X25", 1,
{ DNSLIB_RRTYPE_X25, T_X25, "X25", 1,
{ DNSLIB_RDATA_WF_TEXT }, true },
/* 20 */
{ DNSLIB_RRTYPE_ISDN, "ISDN", 2,
{ DNSLIB_RRTYPE_ISDN, T_ISDN, "ISDN", 2,
{ DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, false },
/* 21 */
{ DNSLIB_RRTYPE_RT, "RT", 2,
{ DNSLIB_RRTYPE_RT, T_RT, "RT", 2,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true },
/* 22 */
{ DNSLIB_RRTYPE_NSAP, "NSAP", 1,
{ DNSLIB_RRTYPE_NSAP, T_NSAP, "NSAP", 1,
{ DNSLIB_RDATA_WF_BINARY }, true },
/* 23 */
{ 23, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ 23, 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 24 */
{ DNSLIB_RRTYPE_SIG, "SIG", 9,
{ DNSLIB_RRTYPE_SIG, T_SIG, "SIG", 9,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG,
DNSLIB_RDATA_WF_SHORT,DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME,
DNSLIB_RDATA_WF_BINARY }, true },
/* 25 */
{ DNSLIB_RRTYPE_KEY, "KEY", 4,
{ DNSLIB_RRTYPE_KEY, T_KEY, "KEY", 4,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true },
/* 26 */
{ DNSLIB_RRTYPE_PX, "PX", 3,
{ DNSLIB_RRTYPE_PX, T_PX, "PX", 3,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME,
DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true },
/* 27 */
{ 27, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ 27, 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 28 */
{ DNSLIB_RRTYPE_AAAA, "AAAA", 1,
{ DNSLIB_RRTYPE_AAAA, T_AAAA, "AAAA", 1,
{ DNSLIB_RDATA_WF_AAAA }, true },
/* 29 */
{ DNSLIB_RRTYPE_LOC, "LOC", 1,
{ DNSLIB_RRTYPE_LOC, T_LOC, "LOC", 1,
{ DNSLIB_RDATA_WF_BINARY }, true },
/* 30 */
{ DNSLIB_RRTYPE_NXT, "NXT", 2,
{ DNSLIB_RRTYPE_NXT, T_NXT, "NXT", 2,
{ DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME,
DNSLIB_RDATA_WF_BINARY }, true },
/* 31 */
{ 31, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ 31, 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 32 */
{ 32, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ 32, 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 33 */
{ DNSLIB_RRTYPE_SRV, "SRV", 4,
{ DNSLIB_RRTYPE_SRV, T_SRV, "SRV", 4,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT,
DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME },
true },
/* 34 */
{ 34, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ 34, 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 35 */
{ DNSLIB_RRTYPE_NAPTR, "NAPTR", 6,
{ DNSLIB_RRTYPE_NAPTR, T_NAPTR, "NAPTR", 6,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true },
/* 36 */
{ DNSLIB_RRTYPE_KX, "KX", 2,
{ DNSLIB_RRTYPE_KX, T_KX, "KX", 2,
{ DNSLIB_RDATA_WF_SHORT,
DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true },
/* 37 */
{ DNSLIB_RRTYPE_CERT, "CERT", 4,
{ DNSLIB_RRTYPE_CERT, T_CERT, "CERT", 4,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT,
DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true },
/* 38 */
{ DNSLIB_RRTYPE_A6, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ DNSLIB_RRTYPE_A6, T_A6, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 39 */
{ DNSLIB_RRTYPE_DNAME, "DNAME", 1,
{ DNSLIB_RRTYPE_DNAME, T_DNAME, "DNAME", 1,
{ DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true },
/* 40 */
{ 40, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ 40, 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 41 */
{ DNSLIB_RRTYPE_OPT, "OPT", 1,
/* OPT has its parser token, but should never be in zone file... */
{ DNSLIB_RRTYPE_OPT, T_OPT, "OPT", 1,
{ DNSLIB_RDATA_WF_BINARY }, true },
/* 42 */
{ DNSLIB_RRTYPE_APL, "APL", DNSLIB_MAX_RDATA_ITEMS,
{ DNSLIB_RRTYPE_APL, T_APL, "APL", DNSLIB_MAX_RDATA_ITEMS,
{ DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL,
DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL,
DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL,
......@@ -219,36 +224,36 @@ static dnslib_rrtype_descriptor_t
DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL,
DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL }, false },
/* 43 */
{ DNSLIB_RRTYPE_DS, "DS", 4,
{ DNSLIB_RRTYPE_DS, T_DS, "DS", 4,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true },
/* 44 */
{ DNSLIB_RRTYPE_SSHFP, "SSHFP", 3,
{ DNSLIB_RRTYPE_SSHFP, T_SSHFP, "SSHFP", 3,
{ DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_BINARY }, true },
/* 45 */
{ DNSLIB_RRTYPE_IPSECKEY, "IPSECKEY", 5,
{ DNSLIB_RRTYPE_IPSECKEY, T_IPSECKEY, "IPSECKEY", 5,
{ DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_IPSECGATEWAY,
DNSLIB_RDATA_WF_BINARY }, false },
/* 46 */
{ DNSLIB_RRTYPE_RRSIG, "RRSIG", 9,
{ DNSLIB_RRTYPE_RRSIG, T_RRSIG, "RRSIG", 9,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_LONG,
DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG,
/*XXX*/ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BINARY, //literal dname used to be here
DNSLIB_RDATA_WF_BINARY }, true },
/* 47 */
{ DNSLIB_RRTYPE_NSEC, "NSEC", 2,
{ DNSLIB_RRTYPE_NSEC, T_NSEC, "NSEC", 2,
/*XXX*/ { DNSLIB_RDATA_WF_BINARY, DNSLIB_RDATA_WF_BINARY }, true }, //same as above
/* 48 */
{ DNSLIB_RRTYPE_DNSKEY, "DNSKEY", 4,
{ DNSLIB_RRTYPE_DNSKEY, T_DNSKEY, "DNSKEY", 4,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true },
/* 49 */
{ DNSLIB_RRTYPE_DHCID, "DHCID", 1, { DNSLIB_RDATA_WF_BINARY }, true },
{ DNSLIB_RRTYPE_DHCID, T_DHCID, "DHCID", 1, { DNSLIB_RDATA_WF_BINARY }, true },
/* 50 */
{ DNSLIB_RRTYPE_NSEC3, "NSEC3", 6,
{ DNSLIB_RRTYPE_NSEC3, T_NSEC3, "NSEC3", 6,
{ DNSLIB_RDATA_WF_BYTE, /* hash type */
DNSLIB_RDATA_WF_BYTE, /* flags */
DNSLIB_RDATA_WF_SHORT, /* iterations */
......@@ -256,7 +261,7 @@ static dnslib_rrtype_descriptor_t
DNSLIB_RDATA_WF_BINARYWITHLENGTH, /* next hashed name */
DNSLIB_RDATA_WF_BINARY /* type bitmap */ }, true },
/* 51 */
{ DNSLIB_RRTYPE_NSEC3PARAM, "NSEC3PARAM", 4,
{ DNSLIB_RRTYPE_NSEC3PARAM, T_NSEC3PARAM, "NSEC3PARAM", 4,
{ DNSLIB_RDATA_WF_BYTE, /* hash type */
DNSLIB_RDATA_WF_BYTE, /* flags */
DNSLIB_RDATA_WF_SHORT, /* iterations */
......@@ -270,7 +275,7 @@ static dnslib_rrtype_descriptor_t
/* There's a GNU extension that works like this: [first ... last] = value */
/* 99 */
[99] = { DNSLIB_RRTYPE_SPF, "SPF", DNSLIB_MAX_RDATA_ITEMS,
[99] = { DNSLIB_RRTYPE_SPF, T_SPF, "SPF", DNSLIB_MAX_RDATA_ITEMS,
{ DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
......@@ -304,7 +309,7 @@ static dnslib_rrtype_descriptor_t
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT,
DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, false },
/* 32769 */
[32769] = { DNSLIB_RRTYPE_DLV, "DLV", 4,
[32769] = { DNSLIB_RRTYPE_DLV, T_DLV, "DLV", 4,
{ DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE,
DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY } },
};
......
......@@ -171,6 +171,7 @@ typedef enum dnslib_rdatawireformat dnslib_rdata_wireformat_t;
struct dnslib_rrtype_descriptor {
uint16_t type; /*!< RR type */
int token; /*< Token used in zoneparser */
const char *name; /*!< Textual name. */
uint8_t length; /*!< Maximum number of RDATA items. */
/*!
......
This diff is collapsed.
/*
* dns.h -- DNS definitions.
*
* Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
*
* See LICENSE for the license.
*
*/
#ifndef _DNS_H_
#define _DNS_H_
#include <stdint.h>
/*!
* \brief A general purpose lookup table.
*/
struct lookup_table {
int id;
const char *name;
};
typedef struct lookup_table lookup_table_type;
/*!
* \brief Enum containing RR class codes.
*/
enum rr_class {
CLASS_IN = 1,
CLASS_CS,
CLASS_CH,
CLASS_HS,
CLASS_NONE = 254,
CLASS_ANY = 255
};
typedef enum rr_class rr_class_type;
enum rr_section {
QUESTION_SECTION,
ANSWER_SECTION,
AUTHORITY_SECTION,
ADDITIONAL_SECTION,
/*
* Use a split additional section to ensure A records appear
* before any AAAA records (this is recommended practice to
* avoid truncating the additional section for IPv4 clients
* that do not specify EDNS0), and AAAA records before other
* types of additional records (such as X25 and ISDN).
* Encode_answer sets the ARCOUNT field of the response packet
* correctly.
*/
ADDITIONAL_A_SECTION = ADDITIONAL_SECTION,
ADDITIONAL_AAAA_SECTION,
ADDITIONAL_OTHER_SECTION,
RR_SECTION_COUNT
};
typedef enum rr_section rr_section_type;
/* Possible OPCODE values */
#define OPCODE_QUERY 0 /* a standard query (QUERY) */
#define OPCODE_IQUERY 1 /* an inverse query (IQUERY) */
#define OPCODE_STATUS 2 /* a server status request (STATUS) */
#define OPCODE_NOTIFY 4 /* NOTIFY */
#define OPCODE_UPDATE 5 /* Dynamic update */
/* Possible RCODE values */
#define RCODE_OK 0 /* No error condition */
#define RCODE_FORMAT 1 /* Format error */
#define RCODE_SERVFAIL 2 /* Server failure */
#define RCODE_NXDOMAIN 3 /* Name Error */
#define RCODE_IMPL 4 /* Not implemented */
#define RCODE_REFUSE 5 /* Refused */
#define RCODE_YXDOMAIN 6 /* name should not exist */
#define RCODE_YXRRSET 7 /* rrset should not exist */
#define RCODE_NXRRSET 8 /* rrset does not exist */
#define RCODE_NOTAUTH 9 /* server not authoritative */
#define RCODE_NOTZONE 10 /* name not inside zone */
/* Standardized NSD return code. Partially maps to DNS RCODE values. */
enum nsd_rc
{
/* Discard the client request. */
NSD_RC_DISCARD = -1,
/* OK, continue normal processing. */
NSD_RC_OK = RCODE_OK,
/* Return the appropriate error code to the client. */
NSD_RC_FORMAT = RCODE_FORMAT,
NSD_RC_SERVFAIL = RCODE_SERVFAIL,
NSD_RC_NXDOMAIN = RCODE_NXDOMAIN,
NSD_RC_IMPL = RCODE_IMPL,
NSD_RC_REFUSE = RCODE_REFUSE,
NSD_RC_NOTAUTH = RCODE_NOTAUTH
};
typedef enum nsd_rc nsd_rc_type;
/* RFC1035 */
#define CLASS_IN 1 /* Class IN */
#define CLASS_CS 2 /* Class CS */
#define CLASS_CH 3 /* Class CHAOS */
#define CLASS_HS 4 /* Class HS */
#define CLASS_NONE 254 /* Class NONE rfc2136 */
#define CLASS_ANY 255 /* Class ANY */
#define TYPE_A 1 /* a host address */
#define TYPE_NS 2 /* an authoritative name server */
#define TYPE_MD 3 /* a mail destination (Obsolete - use MX) */
#define TYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */
#define TYPE_CNAME 5 /* the canonical name for an alias */
#define TYPE_SOA 6 /* marks the start of a zone of authority */
#define TYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */
#define TYPE_MG 8 /* a mail group member (EXPERIMENTAL) */
#define TYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */
#define TYPE_NULL 10 /* a null RR (EXPERIMENTAL) */
#define TYPE_WKS 11 /* a well known service description */
#define TYPE_PTR 12 /* a domain name pointer */
#define TYPE_HINFO 13 /* host information */
#define TYPE_MINFO 14 /* mailbox or mail list information */
#define TYPE_MX 15 /* mail exchange */
#define TYPE_TXT 16 /* text strings */
#define TYPE_RP 17 /* RFC1183 */
#define TYPE_AFSDB 18 /* RFC1183 */
#define TYPE_X25 19 /* RFC1183 */
#define TYPE_ISDN 20 /* RFC1183 */
#define TYPE_RT 21 /* RFC1183 */
#define TYPE_NSAP 22 /* RFC1706 */
#define TYPE_SIG 24 /* 2535typecode */
#define TYPE_KEY 25 /* 2535typecode */
#define TYPE_PX 26 /* RFC2163 */
#define TYPE_AAAA 28 /* ipv6 address */
#define TYPE_LOC 29 /* LOC record RFC1876 */
#define TYPE_NXT 30 /* 2535typecode */
#define TYPE_SRV 33 /* SRV record RFC2782 */
#define TYPE_NAPTR 35 /* RFC2915 */
#define TYPE_KX 36 /* RFC2230 Key Exchange Delegation Record */
#define TYPE_CERT 37 /* RFC2538 */
#define TYPE_A6 38 /* RFC2874 */
#define TYPE_DNAME 39 /* RFC2672 */
#define TYPE_OPT 41 /* Pseudo OPT record... */
#define TYPE_APL 42 /* RFC3123 */
#define TYPE_DS 43 /* RFC 4033, 4034, and 4035 */
#define TYPE_SSHFP 44 /* SSH Key Fingerprint */
#define TYPE_IPSECKEY 45 /* public key for ipsec use. RFC 4025 */
#define TYPE_RRSIG 46 /* RFC 4033, 4034, and 4035 */
#define TYPE_NSEC 47 /* RFC 4033, 4034, and 4035 */
#define TYPE_DNSKEY 48 /* RFC 4033, 4034, and 4035 */
#define TYPE_DHCID 49 /* RFC4701 DHCP information */
#define TYPE_NSEC3 50 /* NSEC3, secure denial, prevents zonewalking */
#define TYPE_NSEC3PARAM 51 /* NSEC3PARAM at zone apex nsec3 parameters */
#define TYPE_SPF 99 /* RFC 4408 */
#define TYPE_TSIG 250
#define TYPE_IXFR 251
#define TYPE_AXFR 252
#define TYPE_MAILB 253 /* A request for mailbox-related records (MB, MG or MR) */
#define TYPE_MAILA 254 /* A request for mail agent RRs (Obsolete - see MX) */
#define TYPE_ANY 255 /* any type (wildcard) */
#define TYPE_DLV 32769 /* RFC 4431 */
#define PSEUDO_TYPE_DLV RRTYPE_DESCRIPTORS_LENGTH
#define MAXLABELLEN 63
#define MAXDOMAINLEN 255
#define MAXRDATALEN 64 /* This is more than enough, think multiple TXT. */
#define MAX_RDLENGTH 65535
/* Maximum size of a single RR. */
#define MAX_RR_SIZE \
(MAXDOMAINLEN + sizeof(uint32_t) + 4*sizeof(uint16_t) + MAX_RDLENGTH)
#define IP4ADDRLEN (32/8)
#define IP6ADDRLEN (128/8)
/*
* The different types of RDATA wireformat data.
*/
enum rdata_wireformat
{
RDATA_WF_COMPRESSED_DNAME, /* Possibly compressed domain name. */
RDATA_WF_UNCOMPRESSED_DNAME, /* Uncompressed domain name. */
RDATA_WF_LITERAL_DNAME, /* Literal (not downcased) dname. */
RDATA_WF_BYTE, /* 8-bit integer. */
RDATA_WF_SHORT, /* 16-bit integer. */
RDATA_WF_LONG, /* 32-bit integer. */
RDATA_WF_TEXT, /* Text string. */
RDATA_WF_A, /* 32-bit IPv4 address. */
RDATA_WF_AAAA, /* 128-bit IPv6 address. */
RDATA_WF_BINARY, /* Binary data (unknown length). */
RDATA_WF_BINARYWITHLENGTH, /* Binary data preceded by 1 byte length */
RDATA_WF_APL, /* APL data. */
RDATA_WF_IPSECGATEWAY /* IPSECKEY gateway ip4, ip6 or dname. */
};
typedef enum rdata_wireformat rdata_wireformat_type;
/*
* The different types of RDATA that can appear in the zone file.
*/
enum rdata_zoneformat
{
RDATA_ZF_DNAME, /* Domain name. */
RDATA_ZF_LITERAL_DNAME, /* DNS name (not lowercased domain name). */
RDATA_ZF_TEXT, /* Text string. */
RDATA_ZF_BYTE, /* 8-bit integer. */
RDATA_ZF_SHORT, /* 16-bit integer. */
RDATA_ZF_LONG, /* 32-bit integer. */
RDATA_ZF_A, /* 32-bit IPv4 address. */
RDATA_ZF_AAAA, /* 128-bit IPv6 address. */
RDATA_ZF_RRTYPE, /* RR type. */
RDATA_ZF_ALGORITHM, /* Cryptographic algorithm. */
RDATA_ZF_CERTIFICATE_TYPE,
RDATA_ZF_PERIOD, /* Time period. */
RDATA_ZF_TIME,
RDATA_ZF_BASE64, /* Base-64 binary data. */
RDATA_ZF_BASE32, /* Base-32 binary data. */
RDATA_ZF_HEX, /* Hexadecimal binary data. */
RDATA_ZF_HEX_LEN, /* Hexadecimal binary data. Skip initial length byte. */
RDATA_ZF_NSAP, /* NSAP. */
RDATA_ZF_APL, /* APL. */
RDATA_ZF_IPSECGATEWAY, /* IPSECKEY gateway ip4, ip6 or dname. */
RDATA_ZF_SERVICES, /* Protocol and port number bitmap. */
RDATA_ZF_NXT, /* NXT type bitmap. */
RDATA_ZF_NSEC, /* NSEC type bitmap. */
RDATA_ZF_LOC, /* Location data. */
RDATA_ZF_UNKNOWN /* Unknown data. */
};
typedef enum rdata_zoneformat rdata_zoneformat_type;
struct rrtype_descriptor
{
uint16_t type; /* RR type */
const char *name; /* Textual name. */
int token; /* Parser token. */
uint32_t minimum; /* Minimum number of RDATAs. */
uint32_t maximum; /* Maximum number of RDATAs. */
uint8_t wireformat[MAXRDATALEN]; /* rdata_wireformat_type */
uint8_t zoneformat[MAXRDATALEN]; /* rdata_zoneformat_type */
};
typedef struct rrtype_descriptor rrtype_descriptor_type;
/*
* Indexed by type. The special type "0" can be used to get a
* descriptor for unknown types (with one binary rdata).
*
* spf + 1
*/
#define RRTYPE_DESCRIPTORS_LENGTH (TYPE_SPF + 1)
rrtype_descriptor_type *rrtype_descriptor_by_name(const char *name);
rrtype_descriptor_type *rrtype_descriptor_by_type(uint16_t type);
const char *rrtype_to_string(uint16_t rrtype);
/*
* Lookup the type in the ztypes lookup table. If not found, check if
* the type uses the "TYPExxx" notation for unknown types.
*
* Return 0 if no type matches.
*/
uint16_t rrtype_from_string(const char *name);
const char *rrclass_to_string(uint16_t rrclass);
uint16_t rrclass_from_string(const char *name);
#ifdef __cplusplus
inline rr_section_type
operator++(rr_section_type &lhs)
{
lhs = (rr_section_type) ((int) lhs + 1);
return lhs;
}
#endif /* __cplusplus */
#endif /* _DNS_H_ */
......@@ -23,7 +23,7 @@
#include "zoneparser.h"
#include "dname.h"
#include "dns.h"
#include "descriptor.h"
#include "zparser.h"
#define YY_NO_INPUT
......@@ -353,10 +353,10 @@ ANY [^\"\n\\]|\\.
static int
rrtype_to_token(const char *word, uint16_t *type)
{
uint16_t t = rrtype_from_string(word);
uint16_t t = dnslib_rrtype_from_string(word);
if (t != 0) {
rrtype_descriptor_type *entry = 0;
entry = rrtype_descriptor_by_type(t);
dnslib_rrtype_descriptor_t *entry = 0;
entry = dnslib_rrtype_descriptor_by_type(t);
*type = t;
/*! \todo entry should return associated token.
......@@ -435,7 +435,7 @@ parse_token(int token, char *yytext, enum lexer_state *lexer_state)
}
/* class */
rrclass = rrclass_from_string(yytext);
rrclass = dnslib_rrclass_from_string(yytext);
if (rrclass != 0) {
yylval.rclass = rrclass;
LEXOUT(("CLASS "));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment