1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

Pull in r3828 from upstream (remove dead code, fix prototypes)

This commit is contained in:
Dag-Erling Smørgrav 2013-04-09 13:08:33 +00:00
parent 2f10c3e258
commit 04f3ab9612
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/ldns/dist/; revision=249306
19 changed files with 45 additions and 286 deletions

36
README
View File

@ -22,6 +22,8 @@ compile on other systems like Solaris and Mac OS X.
REQUIREMENTS REQUIREMENTS
- OpenSSL (Optional, but needed for features like DNSSEC) - OpenSSL (Optional, but needed for features like DNSSEC)
- OpenSSL >= 0.9.7f for DANE support
- OpenSSL >= 1.0.0 for ECDSA and GOST support
- libpcap (Optional, but needed for examples/ldns-dpa) - libpcap (Optional, but needed for examples/ldns-dpa)
- (GNU) libtool (in OSX, that's glibtool, not libtool) - (GNU) libtool (in OSX, that's glibtool, not libtool)
- GNU make - GNU make
@ -29,32 +31,10 @@ REQUIREMENTS
INSTALLATION INSTALLATION
1. Unpack the tarball 1. Unpack the tarball
2. cd ldns-<VERSION> 2. cd ldns-<VERSION>
3. ./configure 3. ./configure --with-examples --with-drill
4. gmake (it needs gnu make to compile, on systems where GNU make is the (optionally compile python bindings too with: --with-pyldns)
default you can just use 'make') 4. make
5. sudo gmake install 5. make install
6. Optional. (cd examples; ./configure; gmake), make example programs included.
7. Optional. (cd drill; ./configure; gmake; gmake install), to build drill.
You can configure and compile it in a separate build directory.
* Examples
There are some examples and dns related tools in the examples/ directory.
These can be built with:
1. cd examples/
2. ./configure [--with-ldns=<path to ldns installation or build>]
3. gmake
* Drill
Drill can be built with:
1. cd drill/
2. ./configure [--with-ldns=<path to ldns installation or build>]
3. gmake
Note that you need to set LD_LIBRARY_PATH if you want to run the binaries
and you have not installed the library to a system directory. You can use
the make target all-static for the examples to run them if you don't want to
install the library.
* Building from subversion repository * Building from subversion repository
@ -84,6 +64,10 @@ We have received patches from the following people, thanks!
o Paul Wouters o Paul Wouters
o Simon Vallet o Simon Vallet
o Ondřej Surý o Ondřej Surý
o Karel Slany
o Havard Eidnes
o Leo Baltus
o Dag-Erling Smørgrav
INFORMATION FOR SPECIFIC OPERATING SYSTEMS INFORMATION FOR SPECIFIC OPERATING SYSTEMS

View File

@ -10,17 +10,14 @@
# the correct versions may need to be set. On those # the correct versions may need to be set. On those
# systems, the 'autoreconf' line should be changed to: # systems, the 'autoreconf' line should be changed to:
# AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf # AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf
# (and these systems probably need gmake instead of make)
# older versions of libtoolize do not support --install # older versions of libtoolize do not support --install
# so you might need to remove that (with newer versions # so you might need to remove that (with newer versions
# it is needed) # it is needed)
libtoolize -c --install libtoolize -c --install
autoreconf --install autoreconf --install
./configure ./configure --with-examples --with-drill # --with-pyldns
make make
make doc # needs doxygen for the html pages make doc # needs doxygen for the html pages
(cd examples && autoreconf && ./configure && make)
(cd drill && autoreconf && ./configure && make)
(cd pcat && autoreconf && ./configure && make) (cd pcat && autoreconf && ./configure && make)
(cd examples/nsd-test && autoreconf && ./configure && make) (cd examples/nsd-test && autoreconf && ./configure && make)

View File

@ -774,7 +774,7 @@ ldns_dnssec_zone_create_nsecs(ldns_dnssec_zone *zone,
/* in dnssec_zone.c */ /* in dnssec_zone.c */
extern int ldns_dname_compare_v(const void *a, const void *b); extern int ldns_dname_compare_v(const void *a, const void *b);
ldns_status static ldns_status
ldns_dnssec_zone_create_nsec3s_mkmap(ldns_dnssec_zone *zone, ldns_dnssec_zone_create_nsec3s_mkmap(ldns_dnssec_zone *zone,
ldns_rr_list *new_rrs, ldns_rr_list *new_rrs,
uint8_t algorithm, uint8_t algorithm,

View File

@ -16,7 +16,7 @@
#include <openssl/md5.h> #include <openssl/md5.h>
ldns_dnssec_data_chain * ldns_dnssec_data_chain *
ldns_dnssec_data_chain_new() ldns_dnssec_data_chain_new(void)
{ {
ldns_dnssec_data_chain *nc = LDNS_CALLOC(ldns_dnssec_data_chain, 1); ldns_dnssec_data_chain *nc = LDNS_CALLOC(ldns_dnssec_data_chain, 1);
if(!nc) return NULL; if(!nc) return NULL;
@ -216,7 +216,7 @@ ldns_dnssec_build_data_chain_other(ldns_resolver *res,
} }
} }
ldns_dnssec_data_chain * static ldns_dnssec_data_chain *
ldns_dnssec_build_data_chain_nokeyname(ldns_resolver *res, ldns_dnssec_build_data_chain_nokeyname(ldns_resolver *res,
uint16_t qflags, uint16_t qflags,
ldns_rr *orig_rr, ldns_rr *orig_rr,
@ -439,7 +439,7 @@ ldns_dnssec_build_data_chain(ldns_resolver *res,
} }
ldns_dnssec_trust_tree * ldns_dnssec_trust_tree *
ldns_dnssec_trust_tree_new() ldns_dnssec_trust_tree_new(void)
{ {
ldns_dnssec_trust_tree *new_tree = LDNS_XMALLOC(ldns_dnssec_trust_tree, ldns_dnssec_trust_tree *new_tree = LDNS_XMALLOC(ldns_dnssec_trust_tree,
1); 1);
@ -495,7 +495,7 @@ print_tabs(FILE *out, size_t nr, uint8_t *map, size_t treedepth)
} }
} }
void static void
ldns_dnssec_trust_tree_print_sm_fmt(FILE *out, ldns_dnssec_trust_tree_print_sm_fmt(FILE *out,
const ldns_output_format *fmt, const ldns_output_format *fmt,
ldns_dnssec_trust_tree *tree, ldns_dnssec_trust_tree *tree,
@ -628,18 +628,6 @@ ldns_dnssec_trust_tree_print_sm_fmt(FILE *out,
} }
} }
void
ldns_dnssec_trust_tree_print_sm(FILE *out,
ldns_dnssec_trust_tree *tree,
size_t tabs,
bool extended,
uint8_t *sibmap,
size_t treedepth)
{
ldns_dnssec_trust_tree_print_sm_fmt(out, ldns_output_format_default,
tree, tabs, extended, sibmap, treedepth);
}
void void
ldns_dnssec_trust_tree_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_trust_tree_print_fmt(FILE *out, const ldns_output_format *fmt,
ldns_dnssec_trust_tree *tree, ldns_dnssec_trust_tree *tree,

View File

@ -7,7 +7,7 @@
#include <ldns/ldns.h> #include <ldns/ldns.h>
ldns_dnssec_rrs * ldns_dnssec_rrs *
ldns_dnssec_rrs_new() ldns_dnssec_rrs_new(void)
{ {
ldns_dnssec_rrs *new_rrs; ldns_dnssec_rrs *new_rrs;
new_rrs = LDNS_MALLOC(ldns_dnssec_rrs); new_rrs = LDNS_MALLOC(ldns_dnssec_rrs);
@ -102,7 +102,7 @@ ldns_dnssec_rrs_print(FILE *out, ldns_dnssec_rrs *rrs)
ldns_dnssec_rrsets * ldns_dnssec_rrsets *
ldns_dnssec_rrsets_new() ldns_dnssec_rrsets_new(void)
{ {
ldns_dnssec_rrsets *new_rrsets; ldns_dnssec_rrsets *new_rrsets;
new_rrsets = LDNS_MALLOC(ldns_dnssec_rrsets); new_rrsets = LDNS_MALLOC(ldns_dnssec_rrsets);
@ -164,7 +164,7 @@ ldns_dnssec_rrsets_set_type(ldns_dnssec_rrsets *rrsets,
return LDNS_STATUS_ERR; return LDNS_STATUS_ERR;
} }
ldns_dnssec_rrsets * static ldns_dnssec_rrsets *
ldns_dnssec_rrsets_new_frm_rr(ldns_rr *rr) ldns_dnssec_rrsets_new_frm_rr(ldns_rr *rr)
{ {
ldns_dnssec_rrsets *new_rrsets; ldns_dnssec_rrsets *new_rrsets;
@ -270,7 +270,7 @@ ldns_dnssec_rrsets_add_rr(ldns_dnssec_rrsets *rrsets, ldns_rr *rr)
return result; return result;
} }
void static void
ldns_dnssec_rrsets_print_soa_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_rrsets_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
ldns_dnssec_rrsets *rrsets, ldns_dnssec_rrsets *rrsets,
bool follow, bool follow,
@ -298,16 +298,6 @@ ldns_dnssec_rrsets_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
} }
} }
void
ldns_dnssec_rrsets_print_soa(FILE *out,
ldns_dnssec_rrsets *rrsets,
bool follow,
bool show_soa)
{
ldns_dnssec_rrsets_print_soa_fmt(out, ldns_output_format_default,
rrsets, follow, show_soa);
}
void void
ldns_dnssec_rrsets_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_rrsets_print_fmt(FILE *out, const ldns_output_format *fmt,
@ -325,7 +315,7 @@ ldns_dnssec_rrsets_print(FILE *out, ldns_dnssec_rrsets *rrsets, bool follow)
} }
ldns_dnssec_name * ldns_dnssec_name *
ldns_dnssec_name_new() ldns_dnssec_name_new(void)
{ {
ldns_dnssec_name *new_name; ldns_dnssec_name *new_name;
@ -428,14 +418,6 @@ ldns_dnssec_name_set_name(ldns_dnssec_name *rrset,
} }
} }
ldns_rr *
ldns_dnssec_name_nsec(ldns_dnssec_name *rrset)
{
if (rrset) {
return rrset->nsec;
}
return NULL;
}
void void
ldns_dnssec_name_set_nsec(ldns_dnssec_name *rrset, ldns_rr *nsec) ldns_dnssec_name_set_nsec(ldns_dnssec_name *rrset, ldns_rr *nsec)
@ -563,7 +545,7 @@ ldns_dnssec_zone_find_rrset(ldns_dnssec_zone *zone,
} }
} }
void static void
ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
ldns_dnssec_name *name, ldns_dnssec_name *name,
bool show_soa) bool show_soa)
@ -589,12 +571,6 @@ ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
} }
} }
void
ldns_dnssec_name_print_soa(FILE *out, ldns_dnssec_name *name, bool show_soa)
{
ldns_dnssec_name_print_soa_fmt(out, ldns_output_format_default,
name, show_soa);
}
void void
ldns_dnssec_name_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_name_print_fmt(FILE *out, const ldns_output_format *fmt,
@ -611,7 +587,7 @@ ldns_dnssec_name_print(FILE *out, ldns_dnssec_name *name)
ldns_dnssec_zone * ldns_dnssec_zone *
ldns_dnssec_zone_new() ldns_dnssec_zone_new(void)
{ {
ldns_dnssec_zone *zone = LDNS_MALLOC(ldns_dnssec_zone); ldns_dnssec_zone *zone = LDNS_MALLOC(ldns_dnssec_zone);
if(!zone) return NULL; if(!zone) return NULL;
@ -777,14 +753,14 @@ ldns_dnssec_zone_new_frm_fp(ldns_dnssec_zone** z, FILE* fp, ldns_rdf* origin,
return ldns_dnssec_zone_new_frm_fp_l(z, fp, origin, ttl, c, NULL); return ldns_dnssec_zone_new_frm_fp_l(z, fp, origin, ttl, c, NULL);
} }
void static void
ldns_dnssec_name_node_free(ldns_rbnode_t *node, void *arg) { ldns_dnssec_name_node_free(ldns_rbnode_t *node, void *arg) {
(void) arg; (void) arg;
ldns_dnssec_name_free((ldns_dnssec_name *)node->data); ldns_dnssec_name_free((ldns_dnssec_name *)node->data);
LDNS_FREE(node); LDNS_FREE(node);
} }
void static void
ldns_dnssec_name_node_deep_free(ldns_rbnode_t *node, void *arg) { ldns_dnssec_name_node_deep_free(ldns_rbnode_t *node, void *arg) {
(void) arg; (void) arg;
ldns_dnssec_name_deep_free((ldns_dnssec_name *)node->data); ldns_dnssec_name_deep_free((ldns_dnssec_name *)node->data);
@ -827,7 +803,7 @@ ldns_dname_compare_v(const void *a, const void *b) {
return ldns_dname_compare((ldns_rdf *)a, (ldns_rdf *)b); return ldns_dname_compare((ldns_rdf *)a, (ldns_rdf *)b);
} }
ldns_rbnode_t * static ldns_rbnode_t *
ldns_dnssec_zone_find_nsec3_original(ldns_dnssec_zone *zone, ldns_dnssec_zone_find_nsec3_original(ldns_dnssec_zone *zone,
ldns_rr *rr) { ldns_rr *rr) {
ldns_rbnode_t *current_node = ldns_rbtree_first(zone->names); ldns_rbnode_t *current_node = ldns_rbtree_first(zone->names);

View File

@ -1157,7 +1157,7 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
return res; return res;
} }
ldns_rdf * static ldns_rdf *
ldns_b32_ext2dname(const ldns_rdf *rdf) ldns_b32_ext2dname(const ldns_rdf *rdf)
{ {
size_t size; size_t size;

4
keys.c
View File

@ -44,7 +44,7 @@ ldns_lookup_table ldns_signing_algorithms[] = {
}; };
ldns_key_list * ldns_key_list *
ldns_key_list_new() ldns_key_list_new(void)
{ {
ldns_key_list *key_list = LDNS_MALLOC(ldns_key_list); ldns_key_list *key_list = LDNS_MALLOC(ldns_key_list);
if (!key_list) { if (!key_list) {
@ -57,7 +57,7 @@ ldns_key_list_new()
} }
ldns_key * ldns_key *
ldns_key_new() ldns_key_new(void)
{ {
ldns_key *newkey; ldns_key *newkey;

View File

@ -32,7 +32,7 @@ struct ldns_dnssec_data_chain_struct
* Creates a new dnssec_chain structure * Creates a new dnssec_chain structure
* \return ldns_dnssec_data_chain * * \return ldns_dnssec_data_chain *
*/ */
ldns_dnssec_data_chain *ldns_dnssec_data_chain_new(); ldns_dnssec_data_chain *ldns_dnssec_data_chain_new(void);
/** /**
* Frees a dnssec_data_chain structure * Frees a dnssec_data_chain structure
@ -137,7 +137,7 @@ struct ldns_dnssec_trust_tree_struct
* *
* \return ldns_dnssec_trust_tree * * \return ldns_dnssec_trust_tree *
*/ */
ldns_dnssec_trust_tree *ldns_dnssec_trust_tree_new(); ldns_dnssec_trust_tree *ldns_dnssec_trust_tree_new(void);
/** /**
* Frees the dnssec_trust_tree recursively * Frees the dnssec_trust_tree recursively

View File

@ -100,7 +100,7 @@ typedef struct ldns_struct_dnssec_zone ldns_dnssec_zone;
* Creates a new entry for 1 pointer to an rr and 1 pointer to the next rrs * Creates a new entry for 1 pointer to an rr and 1 pointer to the next rrs
* \return the allocated data * \return the allocated data
*/ */
ldns_dnssec_rrs *ldns_dnssec_rrs_new(); ldns_dnssec_rrs *ldns_dnssec_rrs_new(void);
/** /**
* Frees the list of rrs, but *not* the individual ldns_rr records * Frees the list of rrs, but *not* the individual ldns_rr records
@ -149,7 +149,7 @@ void ldns_dnssec_rrs_print_fmt(FILE *out,
* Creates a new list (entry) of RRsets * Creates a new list (entry) of RRsets
* \return the newly allocated structure * \return the newly allocated structure
*/ */
ldns_dnssec_rrsets *ldns_dnssec_rrsets_new(); ldns_dnssec_rrsets *ldns_dnssec_rrsets_new(void);
/** /**
* Frees the list of rrsets and their rrs, but *not* the ldns_rr * Frees the list of rrsets and their rrs, but *not* the ldns_rr
@ -224,7 +224,7 @@ void ldns_dnssec_rrsets_print_fmt(FILE *out,
* Create a new data structure for a dnssec name * Create a new data structure for a dnssec name
* \return the allocated structure * \return the allocated structure
*/ */
ldns_dnssec_name *ldns_dnssec_name_new(); ldns_dnssec_name *ldns_dnssec_name_new(void);
/** /**
* Create a new data structure for a dnssec name for the given RR * Create a new data structure for a dnssec name for the given RR
@ -356,7 +356,7 @@ void ldns_dnssec_name_print_fmt(FILE *out,
* Creates a new dnssec_zone structure * Creates a new dnssec_zone structure
* \return the allocated structure * \return the allocated structure
*/ */
ldns_dnssec_zone *ldns_dnssec_zone_new(); ldns_dnssec_zone *ldns_dnssec_zone_new(void);
/** /**
* Create a new dnssec zone from a file. * Create a new dnssec zone from a file.

View File

@ -166,13 +166,13 @@ typedef struct ldns_struct_key_list ldns_key_list;
* Creates a new empty key list * Creates a new empty key list
* \return a new ldns_key_list structure pointer * \return a new ldns_key_list structure pointer
*/ */
ldns_key_list *ldns_key_list_new(); ldns_key_list *ldns_key_list_new(void);
/** /**
* Creates a new empty key structure * Creates a new empty key structure
* \return a new ldns_key * structure * \return a new ldns_key * structure
*/ */
ldns_key *ldns_key_new(); ldns_key *ldns_key_new(void);
/** /**
* Creates a new key based on the algorithm * Creates a new key based on the algorithm

View File

@ -739,7 +739,7 @@ void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data);
* allocates and initializes a ldns_pkt structure. * allocates and initializes a ldns_pkt structure.
* \return pointer to the new packet * \return pointer to the new packet
*/ */
ldns_pkt *ldns_pkt_new(); ldns_pkt *ldns_pkt_new(void);
/** /**
* frees the packet structure and all data that it contains. * frees the packet structure and all data that it contains.

View File

@ -589,7 +589,7 @@ ldns_rr* ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr);
* creates a new rr_list structure. * creates a new rr_list structure.
* \return a new rr_list structure * \return a new rr_list structure
*/ */
ldns_rr_list* ldns_rr_list_new(); ldns_rr_list* ldns_rr_list_new(void);
/** /**
* frees an rr_list structure. * frees an rr_list structure.

View File

@ -379,7 +379,7 @@ ldns_pkt_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr)
return result; return result;
} }
uint16_t static uint16_t
ldns_pkt_section_count(const ldns_pkt *packet, ldns_pkt_section s) ldns_pkt_section_count(const ldns_pkt *packet, ldns_pkt_section s)
{ {
switch(s) { switch(s) {
@ -729,7 +729,7 @@ ldns_pkt_edns(const ldns_pkt *pkt) {
/* Create/destroy/convert functions /* Create/destroy/convert functions
*/ */
ldns_pkt * ldns_pkt *
ldns_pkt_new() ldns_pkt_new(void)
{ {
ldns_pkt *packet; ldns_pkt *packet;
packet = LDNS_MALLOC(ldns_pkt); packet = LDNS_MALLOC(ldns_pkt);

18
parse.c
View File

@ -340,18 +340,6 @@ ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit)
return (ssize_t)i; return (ssize_t)i;
} }
void
ldns_bskipc(ldns_buffer *buffer, char c)
{
while (c == (char) ldns_buffer_read_u8_at(buffer, ldns_buffer_position(buffer))) {
if (ldns_buffer_available_at(buffer,
buffer->_position + sizeof(char), sizeof(char))) {
buffer->_position += sizeof(char);
} else {
return;
}
}
}
void void
ldns_bskipcs(ldns_buffer *buffer, const char *s) ldns_bskipcs(ldns_buffer *buffer, const char *s)
@ -376,12 +364,6 @@ ldns_bskipcs(ldns_buffer *buffer, const char *s)
} }
} }
void
ldns_fskipc(ATTR_UNUSED(FILE *fp), ATTR_UNUSED(char c))
{
}
void void
ldns_fskipcs(FILE *fp, const char *s) ldns_fskipcs(FILE *fp, const char *s)
{ {

View File

@ -436,7 +436,7 @@ ldns_resolver_set_fail(ldns_resolver *r, bool f)
r->_fail =f; r->_fail =f;
} }
void static void
ldns_resolver_set_searchlist_count(ldns_resolver *r, size_t c) ldns_resolver_set_searchlist_count(ldns_resolver *r, size_t c)
{ {
r->_searchlist_count = c; r->_searchlist_count = c;

22
rr.c
View File

@ -936,7 +936,7 @@ ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
} }
ldns_rr_list * ldns_rr_list *
ldns_rr_list_new() ldns_rr_list_new(void)
{ {
ldns_rr_list *rr_list = LDNS_MALLOC(ldns_rr_list); ldns_rr_list *rr_list = LDNS_MALLOC(ldns_rr_list);
if(!rr_list) return NULL; if(!rr_list) return NULL;
@ -1395,25 +1395,7 @@ ldns_rr_list_clone(const ldns_rr_list *rrlist)
} }
int static int
qsort_rr_compare(const void *a, const void *b)
{
const ldns_rr *rr1 = * (const ldns_rr **) a;
const ldns_rr *rr2 = * (const ldns_rr **) b;
if (rr1 == NULL && rr2 == NULL) {
return 0;
}
if (rr1 == NULL) {
return -1;
}
if (rr2 == NULL) {
return 1;
}
return ldns_rr_compare(rr1, rr2);
}
int
qsort_schwartz_rr_compare(const void *a, const void *b) qsort_schwartz_rr_compare(const void *a, const void *b)
{ {
int result = 0; int result = 0;

2
tsig.c
View File

@ -51,7 +51,7 @@ ldns_tsig_keydata_clone(ldns_tsig_credentials *tc)
/* /*
* Makes an exact copy of the wire, but with the tsig rr removed * Makes an exact copy of the wire, but with the tsig rr removed
*/ */
uint8_t * static uint8_t *
ldns_tsig_prepare_pkt_wire(uint8_t *wire, size_t wire_len, size_t *result_len) ldns_tsig_prepare_pkt_wire(uint8_t *wire, size_t wire_len, size_t *result_len)
{ {
uint8_t *wire2 = NULL; uint8_t *wire2 = NULL;

37
util.c
View File

@ -25,43 +25,6 @@
#include <openssl/rand.h> #include <openssl/rand.h>
#endif #endif
/* put this here tmp. for debugging */
void
xprintf_rdf(ldns_rdf *rd)
{
/* assume printable string */
fprintf(stderr, "size\t:%u\n", (unsigned int)ldns_rdf_size(rd));
fprintf(stderr, "type\t:%u\n", (unsigned int)ldns_rdf_get_type(rd));
fprintf(stderr, "data\t:[%.*s]\n", (int)ldns_rdf_size(rd),
(char*)ldns_rdf_data(rd));
}
void
xprintf_rr(ldns_rr *rr)
{
/* assume printable string */
uint16_t count, i;
count = ldns_rr_rd_count(rr);
for(i = 0; i < count; i++) {
fprintf(stderr, "print rd %u\n", (unsigned int) i);
xprintf_rdf(rr->_rdata_fields[i]);
}
}
void xprintf_hex(uint8_t *data, size_t len)
{
size_t i;
for (i = 0; i < len; i++) {
if (i > 0 && i % 20 == 0) {
printf("\t; %u - %u\n", (unsigned int) i - 19, (unsigned int) i);
}
printf("%02x ", (unsigned int) data[i]);
}
printf("\n");
}
ldns_lookup_table * ldns_lookup_table *
ldns_lookup_by_name(ldns_lookup_table *table, const char *name) ldns_lookup_by_name(ldns_lookup_table *table, const char *name)
{ {

113
zone.c
View File

@ -56,103 +56,6 @@ ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr)
return ldns_rr_list_push_rr( ldns_zone_rrs(z), rr); return ldns_rr_list_push_rr( ldns_zone_rrs(z), rr);
} }
/* return a clone of the given rr list, without the glue records
* rr list should be the complete zone
* if present, stripped records are added to the list *glue_records
*/
ldns_rr_list *
ldns_zone_strip_glue_rrs(const ldns_rdf *zone_name, const ldns_rr_list *rrs, ldns_rr_list *glue_rrs)
{
ldns_rr_list *new_list;
/* when do we find glue? It means we find an IP address
* (AAAA/A) for a nameserver listed in the zone
*
* Alg used here:
* first find all the zonecuts (NS records)
* find all the AAAA or A records (can be done it the
* above loop).
*
* Check if the aaaa/a list are subdomains under the
* NS domains.
* If yes -> glue, if no -> not glue
*/
ldns_rr_list *zone_cuts;
ldns_rr_list *addr;
ldns_rr *r, *ns, *a;
ldns_rdf *dname_a, *ns_owner;
uint16_t i,j;
new_list = NULL;
zone_cuts = NULL;
addr = NULL;
new_list = ldns_rr_list_new();
if (!new_list) goto memory_error;
zone_cuts = ldns_rr_list_new();
if (!zone_cuts) goto memory_error;
addr = ldns_rr_list_new();
if (!addr) goto memory_error;
for(i = 0; i < ldns_rr_list_rr_count(rrs); i++) {
r = ldns_rr_list_rr(rrs, i);
if (ldns_rr_get_type(r) == LDNS_RR_TYPE_A ||
ldns_rr_get_type(r) == LDNS_RR_TYPE_AAAA) {
/* possibly glue */
if (!ldns_rr_list_push_rr(addr, r)) goto memory_error;
continue;
}
if (ldns_rr_get_type(r) == LDNS_RR_TYPE_NS) {
/* multiple zones will end up here -
* for now; not a problem
*/
/* don't add NS records for the current zone itself */
if (ldns_rdf_compare(ldns_rr_owner(r),
zone_name) != 0) {
if (!ldns_rr_list_push_rr(zone_cuts, r)) goto memory_error;
}
continue;
}
}
/* will sorting make it quicker ?? */
for(i = 0; i < ldns_rr_list_rr_count(zone_cuts); i++) {
ns = ldns_rr_list_rr(zone_cuts, i);
ns_owner = ldns_rr_owner(ns);
for(j = 0; j < ldns_rr_list_rr_count(addr); j++) {
a = ldns_rr_list_rr(addr, j);
dname_a = ldns_rr_owner(a);
if (ldns_dname_is_subdomain(dname_a, ns_owner)) {
/* GLUE! */
if (glue_rrs) {
if (!ldns_rr_list_push_rr(glue_rrs, a)) goto memory_error;
}
break;
} else {
if (!ldns_rr_list_push_rr(new_list, a)) goto memory_error;
}
}
}
ldns_rr_list_free(addr);
ldns_rr_list_free(zone_cuts);
return new_list;
memory_error:
if (new_list) {
ldns_rr_list_free(new_list);
}
if (zone_cuts) {
ldns_rr_list_free(zone_cuts);
}
if (addr) {
ldns_rr_list_free(addr);
}
return NULL;
}
/* /*
* Get the list of glue records in a zone * Get the list of glue records in a zone
@ -399,22 +302,6 @@ ldns_zone_sort(ldns_zone *zone)
ldns_rr_list_sort(zrr); ldns_rr_list_sort(zrr);
} }
#if 0
/**
* ixfr function. Work on a ldns_zone and remove and add
* the rrs from the rrlist
* \param[in] z the zone to work on
* \param[in] del rr_list to remove from the zone
* \param[in] add rr_list to add to the zone
* \return Tja, wat zouden we eens returnen TODO
*/
void
ldns_zone_ixfr_del_add(ldns_zone *z, ldns_rr_list *del, ldns_rr_list *add)
{
}
#endif
void void
ldns_zone_free(ldns_zone *zone) ldns_zone_free(ldns_zone *zone)
{ {