From: Miek Gieben Date: Tue, 26 Jul 2005 11:48:44 +0000 (+0000) Subject: framework laid for reading zonefiles. Addition to the db.miek.nl zonefile X-Git-Tag: release-0.70~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=294867f9dca46a59cb9fd55cb1c5df92626c262e;p=thirdparty%2Fldns.git framework laid for reading zonefiles. Addition to the db.miek.nl zonefile --- diff --git a/TODO b/TODO index aca18aa3..6173283e 100644 --- a/TODO +++ b/TODO @@ -35,3 +35,4 @@ o private key type? This works, but not (yet) for tsig stuff work in progress - works for RSA/DSA. I want to fold in the tsig stuff as well o install mx, keygen, chaos somewhere, along with manpages?? +o All lookup table stuff in _table types? diff --git a/ldns/parse.h b/ldns/parse.h index 66aba83e..9a5a5aa1 100644 --- a/ldns/parse.h +++ b/ldns/parse.h @@ -13,13 +13,25 @@ #include #include - #define LDNS_PARSE_SKIP_SPACE "\f\n\r\v" #define LDNS_PARSE_NORMAL " \f\n\r\t\v" #define LDNS_PARSE_NO_NL " \t" #define LDNS_MAX_LINELEN 512 #define LDNS_MAX_KEYWORDLEN 32 +/** + * different type of directives in zone files + * We now deal with $TTL, $ORIGIN and $INCLUDE. + * The latter is not implemented in ldns (yet) + */ +enum ldns_enum_directive +{ + LDNS_DIR_TTL, + LDNS_DIR_ORIGIN, + LDNS_DIR_INCLUDE +}; +typedef enum ldns_enum_directive ldns_directive; + /** * returns a token/char from the stream F. * This function deals with ( and ) in the stream, diff --git a/ldns/zone.h b/ldns/zone.h index e25b1d45..a0189f24 100644 --- a/ldns/zone.h +++ b/ldns/zone.h @@ -88,4 +88,8 @@ bool ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr); */ bool ldns_zone_rr_is_glue(ldns_zone *z, ldns_rr *rr); + +ldns_zone * +ldns_zone_new_frm_fp(FILE *fp, ldns_rdf **origin, uint16_t *ttl, ldns_rr_class *c); + #endif /* LDNS_ZONE_H */ diff --git a/parse.c b/parse.c index bb639ff7..2e9e8c53 100644 --- a/parse.c +++ b/parse.c @@ -8,13 +8,18 @@ * See the file LICENSE for the license */ #include - #include - #include #include +ldns_lookup_table ldns_directive_types[] = { + { LDNS_DIR_TTL, "$TTL" }, + { LDNS_DIR_ORIGIN, "$ORIGIN" }, + { LDNS_DIR_INCLUDE, "$INCLUDE" }, + { 0, NULL } +}; + ssize_t ldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit) @@ -300,35 +305,6 @@ tokenread: return (ssize_t)i; } -#if 0 -# not needed anymore - -char * -ldns_str_remove_comment(char *str) -{ - char *s; - int comment; - char *str2; - - comment = 0; - str2 = strdup(str); - - for(s = str2; *s; s++) { - if (*s == ';') { - comment = 1; - } - if (*s == '\n') { - *s = ' '; - comment = 0; - } - if (comment == 1) { - *s = ' '; - } - } - return str2; -} -#endif - void ldns_bskipc(ldns_buffer *buffer, char c) { @@ -394,3 +370,12 @@ ldns_fskipcs(FILE *fp, const char *s) } } } + +ldns_directive +ldns_directive_new_frm_str(const char *str, void **arg) +{ + str = str; + arg = arg; + /* directivearguments */ + return LDNS_DIR_TTL; +} diff --git a/tests/db.miek.nl b/tests/db.miek.nl index f7602273..9f0bc3ff 100644 --- a/tests/db.miek.nl +++ b/tests/db.miek.nl @@ -1,7 +1,7 @@ ; ; BIND data file for miek.nl for internal use ; -$TTL 1H +$TTL 2H @ IN SOA elektron.atoom.net. miekg.atoom.net. ( 2005060700 ; Serial 6H ; Refresh @@ -13,5 +13,10 @@ $TTL 1H @ IN MX 10 elektron.atoom.net. @ IN A 192.168.1.2 -a IN A 192.168.1.2 -www IN CNAME a +god IN A 192.168.1.2 + + +sub.domain.miek.nl IN NS elektron.atoom.net. + IN MX 10 elektron.atoom.net. + +www IN CNAME god diff --git a/zone.c b/zone.c index 47e86f51..4dc47561 100644 --- a/zone.c +++ b/zone.c @@ -60,6 +60,30 @@ ldns_zone_rr_is_glue(ldns_zone *z, ldns_rr *rr) return false; } +/* we don't want state, so we have to give it as arguments */ +/* we regocnize: + * $TTL, $ORIGIN + */ +ldns_zone * +ldns_zone_new_frm_fp(FILE *fp, ldns_rdf **origin, uint16_t *ttl, ldns_rr_class *c) +{ +#if 0 + ldns_zone *newzone; + ldns_rr *rr; +#endif + + /* read until we got a soa, all crap above is discarded + * except $directives + */ + + fp = fp; + origin = origin; + ttl = ttl; + c = c; + + /* re-order stuff with rrsets */ + return NULL; +} #if 0 /**