diff --git a/src/dnslib/descriptor.c b/src/dnslib/descriptor.c index 21aee3a08e384d9a76b2a6d495a908045afa5807..25763e3ba1e140191f1ff556420a717a47191a53 100644 --- a/src/dnslib/descriptor.c +++ b/src/dnslib/descriptor.c @@ -1,11 +1,3 @@ -/* - * File descriptor.c - * Date 12.11.2010 12:06 - * Author: NLabs: NSD team, modifications by Jan Kadlec - * Project: CuteDNS - * Description: - */ - #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -26,14 +18,15 @@ static dnslib_lookup_table_t dns_rrclasses[] = { { DNSLIB_CLASS_HS, "HS" }, /* Hesiod */ { 0, NULL } }; - -static dnslib_rrtype_descriptor_t dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRIPTORS_LENGTH] = { - /* 0 */ +static dnslib_rrtype_descriptor_t + dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRIPTORS_LENGTH] = { + /* 0 */ { 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true }, /* 1 */ { DNSLIB_RRTYPE_A, "A", 1, { DNSLIB_RDATA_WF_A }, true }, /* 2 */ - { DNSLIB_RRTYPE_NS, "NS", 1, { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, + { DNSLIB_RRTYPE_NS, "NS", 1, + { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, /* 3 */ { DNSLIB_RRTYPE_MD, "MD", 1, { DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true }, @@ -45,8 +38,9 @@ static dnslib_rrtype_descriptor_t dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRI { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, /* 6 */ { DNSLIB_RRTYPE_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 }, + { 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_RDATA_WF_COMPRESSED_DNAME }, true }, @@ -70,31 +64,49 @@ static dnslib_rrtype_descriptor_t dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRI { DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, true }, /* 14 */ { DNSLIB_RRTYPE_MINFO, "MINFO", 2, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, + { DNSLIB_RDATA_WF_COMPRESSED_DNAME, + DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, /* 15 */ { DNSLIB_RRTYPE_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_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, false }, + { DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, false }, /* 17 */ { DNSLIB_RRTYPE_RP, "RP", 2, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, + { DNSLIB_RDATA_WF_COMPRESSED_DNAME, + DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, /* 18 */ { DNSLIB_RRTYPE_AFSDB, "AFSDB", 2, { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, true }, @@ -114,12 +126,14 @@ static dnslib_rrtype_descriptor_t dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRI { 23, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true }, /* 24 */ { DNSLIB_RRTYPE_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 }, + { 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_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true }, + { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, + DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true }, /* 26 */ { DNSLIB_RRTYPE_PX, "PX", 3, { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, @@ -134,27 +148,32 @@ static dnslib_rrtype_descriptor_t dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRI { DNSLIB_RDATA_WF_BINARY }, true }, /* 30 */ { DNSLIB_RRTYPE_NXT, "NXT", 2, - { DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, DNSLIB_RDATA_WF_BINARY }, true }, + { DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, + DNSLIB_RDATA_WF_BINARY }, true }, /* 31 */ { 31, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true }, /* 32 */ { 32, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, true }, /* 33 */ { DNSLIB_RRTYPE_SRV, "SRV", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT, - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true }, + { 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 }, /* 35 */ { DNSLIB_RRTYPE_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 }, + { 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_RDATA_WF_SHORT, DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true }, + { DNSLIB_RDATA_WF_SHORT, + DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, true }, /* 37 */ { DNSLIB_RRTYPE_CERT, "CERT", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true }, + { 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 }, /* 39 */ @@ -167,43 +186,65 @@ static dnslib_rrtype_descriptor_t dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRI { DNSLIB_RDATA_WF_BINARY }, true }, /* 42 */ { DNSLIB_RRTYPE_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, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL }, false }, + { DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, + DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL }, false }, /* 43 */ { DNSLIB_RRTYPE_DS, "DS", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true }, + { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, + DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true }, /* 44 */ { DNSLIB_RRTYPE_SSHFP, "SSHFP", 3, - { DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true }, + { DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, + DNSLIB_RDATA_WF_BINARY }, true }, /* 45 */ { DNSLIB_RRTYPE_IPSECKEY, "IPSECKEY", 5, - { DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_IPSECGATEWAY, + { 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_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_LITERAL_DNAME, DNSLIB_RDATA_WF_BINARY }, true }, + { 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_LITERAL_DNAME, + DNSLIB_RDATA_WF_BINARY }, true }, /* 47 */ { DNSLIB_RRTYPE_NSEC, "NSEC", 2, { DNSLIB_RDATA_WF_LITERAL_DNAME, DNSLIB_RDATA_WF_BINARY }, true }, /* 48 */ { DNSLIB_RRTYPE_DNSKEY, "DNSKEY", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, true }, + { 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 }, /* 50 */ @@ -230,52 +271,73 @@ static dnslib_rrtype_descriptor_t dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DESCRI /* 99 */ [99] = { DNSLIB_RRTYPE_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, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, false }, + { DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, + DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, false }, /* 32769 */ /* [100] = { DNSLIB_RRTYPE_DLV, "DLV", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY } },*/ + { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, + DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY } },*/ }; -dnslib_lookup_table_t *dnslib_lookup_by_name( dnslib_lookup_table_t *table, const char *name ) +dnslib_lookup_table_t *dnslib_lookup_by_name(dnslib_lookup_table_t *table, + const char *name) { - while (table->name != NULL) { - if (strcasecmp(name, table->name) == 0) - return table; - table++; - } + while (table->name != NULL) { + if (strcasecmp(name, table->name) == 0) { + return table; + } + table++; + } - return NULL; + return NULL; } -dnslib_lookup_table_t *dnslib_lookup_by_id( dnslib_lookup_table_t *table, int id ) +dnslib_lookup_table_t *dnslib_lookup_by_id(dnslib_lookup_table_t *table, + int id) { - while (table->name != NULL) { - if (table->id == id) - return table; - table++; - } + while (table->name != NULL) { + if (table->id == id) { + return table; + } + table++; + } - return NULL; + return NULL; } /*! * \brief Strlcpy - safe string copy function, based on FreeBSD implementation. - * + * * http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/ * * \param dst Destination string. @@ -284,147 +346,158 @@ dnslib_lookup_table_t *dnslib_lookup_by_id( dnslib_lookup_table_t *table, int id * * \return strlen(src), if retval >= siz, truncation occurred. */ -size_t dnslib_strlcpy( char *dst, const char *src, size_t siz ) +size_t dnslib_strlcpy(char *dst, const char *src, size_t siz) { - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) { + break; + } + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) { + *d = '\0'; /* NUL-terminate dst */ + } + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ } -dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_type( uint16_t type ) +dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_type(uint16_t type) { - if (type < DNSLIB_RRTYPE_DESCRIPTORS_LENGTH) - return &dnslib_rrtype_descriptors[type]; - else if (type == DNSLIB_RRTYPE_DLV) - return &dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DS]; - return &dnslib_rrtype_descriptors[0]; + if (type < DNSLIB_RRTYPE_DESCRIPTORS_LENGTH) { + return &dnslib_rrtype_descriptors[type]; + } else if (type == DNSLIB_RRTYPE_DLV) { + return &dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DS]; + } + return &dnslib_rrtype_descriptors[0]; } //Will we ever need this? XXX -dnslib_rrtype_descriptor_t *rrtype_descriptor_by_name( const char *name ) +dnslib_rrtype_descriptor_t *rrtype_descriptor_by_name(const char *name) { - int i; - - for (i = 0; i < DNSLIB_RRTYPE_DESCRIPTORS_LENGTH; ++i) { - if (dnslib_rrtype_descriptors[i].name - && strcasecmp(dnslib_rrtype_descriptors[i].name, name) == 0) - { - return &dnslib_rrtype_descriptors[i]; - } - } - - if (dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DLV].name - && strcasecmp(dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DLV].name, - name) == 0) - { - return &dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DS]; - } - - return NULL; + int i; + + for (i = 0; i < DNSLIB_RRTYPE_DESCRIPTORS_LENGTH; ++i) { + if (dnslib_rrtype_descriptors[i].name && + strcasecmp(dnslib_rrtype_descriptors[i].name, name) == 0) { + return &dnslib_rrtype_descriptors[i]; + } + } + + if (dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DLV].name && + strcasecmp(dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DLV].name, + name) == 0) { + return &dnslib_rrtype_descriptors[DNSLIB_RRTYPE_DS]; + } + + return NULL; } -const char *dnslib_rrtype_to_string( uint16_t rrtype ) +const char *dnslib_rrtype_to_string(uint16_t rrtype) { - static char buf[20]; - dnslib_rrtype_descriptor_t *descriptor = - dnslib_rrtype_descriptor_by_type(rrtype); - if (descriptor->name) { - return descriptor->name; - } else { - snprintf(buf, sizeof(buf), "TYPE%d", (int) rrtype); - return buf; - } + static char buf[20]; + dnslib_rrtype_descriptor_t *descriptor = + dnslib_rrtype_descriptor_by_type(rrtype); + if (descriptor->name) { + return descriptor->name; + } else { + snprintf(buf, sizeof(buf), "TYPE%d", (int) rrtype); + return buf; + } } -uint16_t dnslib_rrtype_from_string( const char *name ) +uint16_t dnslib_rrtype_from_string(const char *name) { - char *end; - long rrtype; - dnslib_rrtype_descriptor_t *entry; - - entry = rrtype_descriptor_by_name(name); - if (entry) { - return entry->type; - } - - if (strlen(name) < 5) - return 0; - - if (strncasecmp(name, "TYPE", 4) != 0) - return 0; - - if (!isdigit((int)name[4])) - return 0; - - /* The rest from the string must be a number. */ - rrtype = strtol(name + 4, &end, 10); - if (*end != '\0') - return 0; - if (rrtype < 0 || rrtype > 65535L) - return 0; - - return (uint16_t) rrtype; + char *end; + long rrtype; + dnslib_rrtype_descriptor_t *entry; + + entry = rrtype_descriptor_by_name(name); + if (entry) { + return entry->type; + } + + if (strlen(name) < 5) { + return 0; + } + + if (strncasecmp(name, "TYPE", 4) != 0) { + return 0; + } + + if (!isdigit((int)name[4])) { + return 0; + } + + /* The rest from the string must be a number. */ + rrtype = strtol(name + 4, &end, 10); + if (*end != '\0') { + return 0; + } + if (rrtype < 0 || rrtype > 65535L) { + return 0; + } + + return (uint16_t) rrtype; } const char *dnslib_rrclass_to_string(uint16_t rrclass) { - static char buf[20]; - dnslib_lookup_table_t *entry = dnslib_lookup_by_id(dns_rrclasses, rrclass); - if (entry) { - assert(strlen(entry->name) < sizeof(buf)); //XXX check it using other way - dnslib_strlcpy(buf, entry->name, sizeof(buf)); - } else { - snprintf(buf, sizeof(buf), "CLASS%d", (int) rrclass); - } - return buf; + static char buf[20]; + dnslib_lookup_table_t *entry = dnslib_lookup_by_id(dns_rrclasses, + rrclass); + if (entry) { + assert(strlen(entry->name) < sizeof(buf)); + dnslib_strlcpy(buf, entry->name, sizeof(buf)); + } else { + snprintf(buf, sizeof(buf), "CLASS%d", (int) rrclass); + } + return buf; } uint16_t dnslib_rrclass_from_string(const char *name) { - char *end; - long rrclass; - dnslib_lookup_table_t *entry; - - entry = dnslib_lookup_by_name(dns_rrclasses, name); - if (entry) { - return (uint16_t) entry->id; - } - - if (strlen(name) < 6) - return 0; - - if (strncasecmp(name, "CLASS", 5) != 0) - return 0; - - if (!isdigit((int)name[5])) - return 0; - - // The rest from the string must be a number. - rrclass = strtol(name + 5, &end, 10); - if (*end != '\0') - return 0; - if (rrclass < 0 || rrclass > 65535L) - return 0; - - return (uint16_t) rrclass; + char *end; + long rrclass; + dnslib_lookup_table_t *entry; + + entry = dnslib_lookup_by_name(dns_rrclasses, name); + if (entry) { + return (uint16_t) entry->id; + } + + if (strlen(name) < 6) { + return 0; + } + + if (strncasecmp(name, "CLASS", 5) != 0) { + return 0; + } + + if (!isdigit((int)name[5])) { + return 0; + } + + // The rest from the string must be a number. + rrclass = strtol(name + 5, &end, 10); + if (*end != '\0') { + return 0; + } + if (rrclass < 0 || rrclass > 65535L) { + return 0; + } + + return (uint16_t) rrclass; } -/* end of file descriptor.c */ diff --git a/src/dnslib/descriptor.h b/src/dnslib/descriptor.h index 58197d98c69d3cc22276147d19ad03b7632de6a6..695e386393e3c541f4f0df338539517cb4cb3cbc 100644 --- a/src/dnslib/descriptor.h +++ b/src/dnslib/descriptor.h @@ -1,26 +1,27 @@ -/* - * File: descriptor.h - * Date: 12.11.2010 11:13 - * Author: jan - * Project: - * Description: +/*! + * \file descriptor.h + * + * \author Jan Kadlec <jan.kadlec@nic.cz>, most of the work by NSD team + * + * \brief Contains resource record descriptor and its API + * + * \addtogroup dnslib + * @{ */ - -#ifndef __DESCRIPTOR_H__ -#define __DESCRIPTOR_H__ +#ifndef _CUTEDNS_DNSLIB_DESCRIPTOR_H_ +#define _CUTEDNS_DNSLIB_DESCRIPTOR_H_ #include <stdint.h> #include <stdbool.h> #include "common.h" -enum mxrdtln -{ +enum mxrdtln { DNSLIB_MAX_RDATA_ITEMS = 64, DNSLIB_MAX_RDATA_ITEM_SIZE = 255, DNSLIB_MAX_RDATA_WIRE_SIZE = - DNSLIB_MAX_RDATA_ITEMS * DNSLIB_MAX_RDATA_ITEM_SIZE + DNSLIB_MAX_RDATA_ITEMS * DNSLIB_MAX_RDATA_ITEM_SIZE }; //#define MAXRDATALEN 64 @@ -30,8 +31,8 @@ enum mxrdtln * \brief A general purpose lookup table. */ struct dnslib_lookup_table { - int id; - const char *name; + int id; + const char *name; }; typedef struct dnslib_lookup_table dnslib_lookup_table_t; @@ -39,87 +40,97 @@ typedef struct dnslib_lookup_table dnslib_lookup_table_t; /*! * \brief Enum containing RR class codes. */ -enum dnslib_rr_class -{ - DNSLIB_CLASS_IN, - DNSLIB_CLASS_CS, - DNSLIB_CLASS_CH, - DNSLIB_CLASS_HS, - DNSLIB_CLASS_NONE = 254, - DNSLIB_CLASS_ANY = 255 +enum dnslib_rr_class { + DNSLIB_CLASS_IN, + DNSLIB_CLASS_CS, + DNSLIB_CLASS_CH, + DNSLIB_CLASS_HS, + DNSLIB_CLASS_NONE = 254, + DNSLIB_CLASS_ANY = 255 }; typedef enum dnslib_rr_class dnslib_rr_class_t; -enum dnslib_rr_type -{ - DNSLIB_RRTYPE_UNKNOWN, /* 0 - an unknown type */ - DNSLIB_RRTYPE_A, /* 1 - a host address */ - DNSLIB_RRTYPE_NS, /* 2 - an authoritative name server */ - DNSLIB_RRTYPE_MD, /* 3 - a mail destination (Obsolete - use MX) */ - DNSLIB_RRTYPE_MF, /* 4 - a mail forwarder (Obsolete - use MX) */ - DNSLIB_RRTYPE_CNAME, /* 5 - the canonical name for an alias */ - DNSLIB_RRTYPE_SOA, /* 6 - marks the start of a zone of authority */ - DNSLIB_RRTYPE_MB, /* 7 - a mailbox domain name (EXPERIMENTAL) */ - DNSLIB_RRTYPE_MG, /* 8 - a mail group member (EXPERIMENTAL) */ - DNSLIB_RRTYPE_MR, /* 9 - a mail rename domain name (EXPERIMENTAL) */ - DNSLIB_RRTYPE_NULL, /* 10 - a null RR (EXPERIMENTAL) */ - DNSLIB_RRTYPE_WKS, /* 11 - a well known service description */ - DNSLIB_RRTYPE_PTR, /* 12 - a domain name pointer */ - DNSLIB_RRTYPE_HINFO, /* 13 - host information */ - DNSLIB_RRTYPE_MINFO, /* 14 - mailbox or mail list information */ - DNSLIB_RRTYPE_MX, /* 15 - mail exchange */ - DNSLIB_RRTYPE_TXT, /* 16 - text strings */ - DNSLIB_RRTYPE_RP, /* 17 - RFC1183 */ - DNSLIB_RRTYPE_AFSDB, /* 18 - RFC1183 */ - DNSLIB_RRTYPE_X25, /* 19 - RFC1183 */ - DNSLIB_RRTYPE_ISDN, /* 20 - RFC1183 */ - DNSLIB_RRTYPE_RT, /* 21 - RFC1183 */ - DNSLIB_RRTYPE_NSAP, /* 22 - RFC1706 */ - - DNSLIB_RRTYPE_SIG = 24, /* 24 - 2535typecode */ - DNSLIB_RRTYPE_KEY, /* 25 - 2535typecode */ - DNSLIB_RRTYPE_PX, /* 26 - RFC2163 */ - - DNSLIB_RRTYPE_AAAA = 28, /* 28 - ipv6 address */ - DNSLIB_RRTYPE_LOC, /* 29 - LOC record RFC1876 */ - DNSLIB_RRTYPE_NXT, /* 30 - 2535typecode */ - - DNSLIB_RRTYPE_SRV = 33, /* 33 - SRV record RFC2782 */ - - DNSLIB_RRTYPE_NAPTR = 35, /* 35 - RFC2915 */ - DNSLIB_RRTYPE_KX, /* 36 - RFC2230 Key Exchange Delegation Record */ - DNSLIB_RRTYPE_CERT, /* 37 - RFC2538 */ - DNSLIB_RRTYPE_A6, /* 38 - RFC2874 */ - DNSLIB_RRTYPE_DNAME, /* 39 - RFC2672 */ - - DNSLIB_RRTYPE_OPT = 41, /* 41 - Pseudo OPT record... */ - DNSLIB_RRTYPE_APL, /* 42 - RFC3123 */ - DNSLIB_RRTYPE_DS, /* 43 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_SSHFP, /* 44 - SSH Key Fingerprint */ - DNSLIB_RRTYPE_IPSECKEY, /* 45 - public key for ipsec use. RFC 4025 */ - DNSLIB_RRTYPE_RRSIG, /* 46 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_NSEC, /* 47 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_DNSKEY, /* 48 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_DHCID, /* 49 - RFC4701 DHCP information */ - DNSLIB_RRTYPE_NSEC3, /* 50 - NSEC3, secure denial, prevents zonewalking */ - DNSLIB_RRTYPE_NSEC3PARAM, /* 51 - NSEC3PARAM at zone apex nsec3 parameters */ - - /* TODO consider some better way of doing this, indices too high */ - - DNSLIB_RRTYPE_SPF = 99, /* RFC 4408 */ - - // not designating any RRs - DNSLIB_RRTYPE_TSIG = 250, - DNSLIB_RRTYPE_IXFR = 251, - DNSLIB_RRTYPE_AXFR = 252, - DNSLIB_RRTYPE_MAILB = 253, /* A request for mailbox-related records (MB, MG or MR) */ - DNSLIB_RRTYPE_MAILA = 254, /* A request for mail agent RRs (Obsolete - see MX) */ - DNSLIB_RRTYPE_ANY = 255, /* any type (wildcard) */ - - // totally weird numbers (cannot use for indexing) - DNSLIB_RRTYPE_TA = 32768, /* DNSSEC Trust Authorities ([Weiler] 2005-12-13) */ - DNSLIB_RRTYPE_DLV = 32769/* RFC 4431 */ +enum dnslib_rr_type { + DNSLIB_RRTYPE_UNKNOWN, /*!< 0 - an unknown type */ + DNSLIB_RRTYPE_A, /*!< 1 - a host address */ + DNSLIB_RRTYPE_NS, /*!< 2 - an authoritative name server */ + DNSLIB_RRTYPE_MD, /*!< 3 - a mail destination (Obsolete - use MX) */ + DNSLIB_RRTYPE_MF, /*!< 4 - a mail forwarder (Obsolete - use MX) */ + DNSLIB_RRTYPE_CNAME, /*!< 5 - the canonical name for an alias */ + DNSLIB_RRTYPE_SOA, /*!< 6 - marks the start of a zone of authority */ + DNSLIB_RRTYPE_MB, /*!< 7 - a mailbox domain name (EXPERIMENTAL) */ + DNSLIB_RRTYPE_MG, /*!< 8 - a mail group member (EXPERIMENTAL) */ + DNSLIB_RRTYPE_MR, /*!< 9 - a mail rename domain name (EXPERIMENTAL) */ + DNSLIB_RRTYPE_NULL, /*!< 10 - a null RR (EXPERIMENTAL) */ + DNSLIB_RRTYPE_WKS, /*!< 11 - a well known service description */ + DNSLIB_RRTYPE_PTR, /*!< 12 - a domain name pointer */ + DNSLIB_RRTYPE_HINFO, /*!< 13 - host information */ + DNSLIB_RRTYPE_MINFO, /*!< 14 - mailbox or mail list information */ + DNSLIB_RRTYPE_MX, /*!< 15 - mail exchange */ + DNSLIB_RRTYPE_TXT, /*!< 16 - text strings */ + DNSLIB_RRTYPE_RP, /*!< 17 - RFC1183 */ + DNSLIB_RRTYPE_AFSDB, /*!< 18 - RFC1183 */ + DNSLIB_RRTYPE_X25, /*!< 19 - RFC1183 */ + DNSLIB_RRTYPE_ISDN, /*!< 20 - RFC1183 */ + DNSLIB_RRTYPE_RT, /*!< 21 - RFC1183 */ + DNSLIB_RRTYPE_NSAP, /*!< 22 - RFC1706 */ + + DNSLIB_RRTYPE_SIG = 24, /*!< 24 - 2535typecode */ + DNSLIB_RRTYPE_KEY, /*!< 25 - 2535typecode */ + DNSLIB_RRTYPE_PX, /*!< 26 - RFC2163 */ + + DNSLIB_RRTYPE_AAAA = 28, /*!< 28 - ipv6 address */ + DNSLIB_RRTYPE_LOC, /*!< 29 - LOC record RFC1876 */ + DNSLIB_RRTYPE_NXT, /*!< 30 - 2535typecode */ + + DNSLIB_RRTYPE_SRV = 33, /*!< 33 - SRV record RFC2782 */ + + DNSLIB_RRTYPE_NAPTR = 35, /*!< 35 - RFC2915 */ + DNSLIB_RRTYPE_KX, /*!< 36 - RFC2230 Key Exchange Delegation Record */ + DNSLIB_RRTYPE_CERT, /*!< 37 - RFC2538 */ + DNSLIB_RRTYPE_A6, /*!< 38 - RFC2874 */ + DNSLIB_RRTYPE_DNAME, /*!< 39 - RFC2672 */ + + DNSLIB_RRTYPE_OPT = 41, /*!< 41 - Pseudo OPT record... */ + DNSLIB_RRTYPE_APL, /*!< 42 - RFC3123 */ + DNSLIB_RRTYPE_DS, /*!< 43 - RFC 4033, 4034, and 4035 */ + DNSLIB_RRTYPE_SSHFP, /*!< 44 - SSH Key Fingerprint */ + DNSLIB_RRTYPE_IPSECKEY, /*!< 45 - public key for ipsec use. RFC 4025 */ + DNSLIB_RRTYPE_RRSIG, /*!< 46 - RFC 4033, 4034, and 4035 */ + DNSLIB_RRTYPE_NSEC, /*!< 47 - RFC 4033, 4034, and 4035 */ + DNSLIB_RRTYPE_DNSKEY, /*!< 48 - RFC 4033, 4034, and 4035 */ + DNSLIB_RRTYPE_DHCID, /*!< 49 - RFC4701 DHCP information */ + /*! + * \brief 50 - NSEC3, secure denial, prevents zonewalking + */ + DNSLIB_RRTYPE_NSEC3, + /*! + * \brief 51 - NSEC3PARAM at zone apex nsec3 parameters + */ + DNSLIB_RRTYPE_NSEC3PARAM, + + /* TODO consider some better way of doing this, indices too high */ + + DNSLIB_RRTYPE_SPF = 99, /*!< RFC 4408 */ + + // not designating any RRs + DNSLIB_RRTYPE_TSIG = 250, + DNSLIB_RRTYPE_IXFR = 251, + DNSLIB_RRTYPE_AXFR = 252, + /*! + * \brief A request for mailbox-related records (MB, MG or MR) + */ + DNSLIB_RRTYPE_MAILB = 253, + /*! + * \brief A request for mail agent RRs (Obsolete - see MX) + */ + DNSLIB_RRTYPE_MAILA = 254, + DNSLIB_RRTYPE_ANY = 255, /*!< any type (wildcard) */ + + // totally weird numbers (cannot use for indexing) + DNSLIB_RRTYPE_TA = 32768, /*!< DNSSEC Trust Authorities */ + DNSLIB_RRTYPE_DLV = 32769 /*!< RFC 4431 */ }; /*! @@ -131,21 +142,26 @@ typedef enum dnslib_rr_type dnslib_rr_type_t; static uint const DNSLIB_RRTYPE_LAST = DNSLIB_RRTYPE_NSEC3PARAM; -enum dnslib_rdata_wireformat -{ - DNSLIB_RDATA_WF_COMPRESSED_DNAME, /* Possibly compressed domain name. */ - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, /* Uncompressed domain name. */ - DNSLIB_RDATA_WF_LITERAL_DNAME, /* Literal (not downcased) dname. */ - DNSLIB_RDATA_WF_BYTE, /* 8-bit integer. */ - DNSLIB_RDATA_WF_SHORT, /* 16-bit integer. */ - DNSLIB_RDATA_WF_LONG, /* 32-bit integer. */ - DNSLIB_RDATA_WF_TEXT, /* Text string. */ - DNSLIB_RDATA_WF_A, /* 32-bit IPv4 address. */ - DNSLIB_RDATA_WF_AAAA, /* 128-bit IPv6 address. */ - DNSLIB_RDATA_WF_BINARY, /* Binary data (unknown length). */ - DNSLIB_RDATA_WF_BINARYWITHLENGTH, /* Binary data preceded by 1 byte length */ - DNSLIB_RDATA_WF_APL, /* APL data. */ - DNSLIB_RDATA_WF_IPSECGATEWAY /* IPSECKEY gateway ip4, ip6 or dname. */ +enum dnslib_rdata_wireformat { + /*! + * \brief Possibly compressed domain name. + */ + DNSLIB_RDATA_WF_COMPRESSED_DNAME, + DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, /*!< Uncompressed domain name. */ + DNSLIB_RDATA_WF_LITERAL_DNAME, /*!< Literal (not downcased) dname. */ + DNSLIB_RDATA_WF_BYTE, /*!< 8-bit integer. */ + DNSLIB_RDATA_WF_SHORT, /*!< 16-bit integer. */ + DNSLIB_RDATA_WF_LONG, /*!< 32-bit integer. */ + DNSLIB_RDATA_WF_TEXT, /*!< Text string. */ + DNSLIB_RDATA_WF_A, /*!< 32-bit IPv4 address. */ + DNSLIB_RDATA_WF_AAAA, /*!< 128-bit IPv6 address. */ + DNSLIB_RDATA_WF_BINARY, /*!< Binary data (unknown length). */ + /*! + * \brief Binary data preceded by 1 byte length + */ + DNSLIB_RDATA_WF_BINARYWITHLENGTH, + DNSLIB_RDATA_WF_APL, /*!< APL data. */ + DNSLIB_RDATA_WF_IPSECGATEWAY /*!< IPSECKEY gateway ip4, ip6 or dname. */ }; /*! @@ -153,13 +169,15 @@ enum dnslib_rdata_wireformat */ typedef enum dnslib_rdatawireformat dnslib_rdata_wireformat_t; -struct dnslib_rrtype_descriptor -{ - uint16_t type; /* RR type */ - const char *name; /* Textual name. */ - uint8_t length; /* Maximum number of RDATA items. */ - uint8_t wireformat[DNSLIB_MAX_RDATA_ITEMS]; /* rdata_wireformat_type */ - bool fixed_items; /* Has fixed number of RDATA items? */ +struct dnslib_rrtype_descriptor { + uint16_t type; /*!< RR type */ + const char *name; /*!< Textual name. */ + uint8_t length; /*!< Maximum number of RDATA items. */ + /*! + * \brief rdata_wireformat_type + */ + uint8_t wireformat[DNSLIB_MAX_RDATA_ITEMS]; + bool fixed_items; /*!< Has fixed number of RDATA items? */ }; /*! @@ -173,9 +191,9 @@ typedef struct dnslib_rrtype_descriptor dnslib_rrtype_descriptor_t; * \param type Code of RR type whose descriptor should be returned. * * \return RR descriptor for given type code, NULL descriptor if - * unknown type. + * unknown type. */ -dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_type( uint16_t type ); +dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_type(uint16_t type); /*! * \brief Gets RR descriptor for given RR name. @@ -183,9 +201,9 @@ dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_type( uint16_t type ); * \param name Mnemonic of RR type whose descriptor should be returned. * * \return RR descriptor for given name, NULL descriptor if - * unknown type. + * unknown type. */ -dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_name( const char *name ); +dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_name(const char *name); /*! * \brief Converts numeric type representation to mnemonic string. @@ -194,7 +212,7 @@ dnslib_rrtype_descriptor_t *dnslib_rrtype_descriptor_by_name( const char *name ) * * \return Mnemonic string if found, str(TYPE[rrtype]) otherwise. */ -const char *dnslib_rrtype_to_string( uint16_t rrtype ); +const char *dnslib_rrtype_to_string(uint16_t rrtype); /*! * \brief Converts mnemonic string representation of a type to numeric one. @@ -203,17 +221,17 @@ const char *dnslib_rrtype_to_string( uint16_t rrtype ); * * \return Correct code if found, 0 otherwise. */ -uint16_t dnslib_rrtype_from_string( const char *name ); +uint16_t dnslib_rrtype_from_string(const char *name); /*! * \brief Converts numeric class representation to string one. * * \param rrclass Class code to be converted. * - * \return String represenation of class if found, - * str(CLASS[rrclass]) otherwise. + * \return String represenation of class if found, + * str(CLASS[rrclass]) otherwise. */ -const char *dnslib_rrclass_to_string( uint16_t rrclass ); +const char *dnslib_rrclass_to_string(uint16_t rrclass); /*! * \brief Converts string representation of a class to numeric one. @@ -222,8 +240,9 @@ const char *dnslib_rrclass_to_string( uint16_t rrclass ); * * \return Correct code if found, 0 otherwise. */ -uint16_t dnslib_rrclass_from_string( const char *name ); +uint16_t dnslib_rrclass_from_string(const char *name); + +#endif /* _CUTEDNS_DNSLIB_DESCRIPTOR_H_ */ -#endif +/*! @} */ -/* end of file descriptor.h */