From: Miek Gieben Date: Thu, 27 Jan 2005 12:21:02 +0000 (+0000) Subject: use ldns_dname where appropiate X-Git-Tag: release-0.50~521 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70041fa6a64ec6e3c706fa719477e39cc5ac2013;p=thirdparty%2Fldns.git use ldns_dname where appropiate some other, non-working network changes --- diff --git a/doc/overview b/doc/overview index 56c79efb..6bfcc638 100644 --- a/doc/overview +++ b/doc/overview @@ -3,6 +3,14 @@ ldns - Overview document 1. Introduction +1.1 Global decisions + o IP4/6 agnostic - only the resolver at is lowest level will handle/see + this. + o Keep an eye on a windows API for portability issues. + o Compression happens only in the WIRE module. For compressible RR + is known by the library. + + 2. Different parts of ldns: - CLIENT - @@ -95,9 +103,14 @@ information which is then stored in RR structures. 5. RESOLVER module and CENTRAL structures Interface The resolver module always returns pkt structure. + The function-call parameters have not yet been decided on. +Also the resolver module will need to access some of the +to_wire and from_wire function to creates ldn_pkt's from +the data it receives (arrow not drawn). + 6. STR module and CENTRAL structures Interface Convert to and from strings. This module could be used to read in a zone file and convert the text strings to diff --git a/ldns/str2host.h b/ldns/str2host.h index 3fbc13e5..2a89079b 100644 --- a/ldns/str2host.h +++ b/ldns/str2host.h @@ -14,7 +14,6 @@ ldns_status ldns_str2rdf_int8(ldns_rdf **, const uint8_t *); ldns_status ldns_str2rdf_int16(ldns_rdf **, const uint8_t *); ldns_status ldns_str2rdf_int32(ldns_rdf **, const uint8_t *); ldns_status ldns_str2rdf_time(ldns_rdf **, const uint8_t *); -ldns_status ldns_str2rdf_dname(ldns_rdf **, const uint8_t*); ldns_status ldns_str2rdf_a(ldns_rdf **, const uint8_t*); ldns_status ldns_str2rdf_aaaa(ldns_rdf **, const uint8_t*); ldns_status ldns_str2rdf_str(ldns_rdf **, const uint8_t*); @@ -33,4 +32,6 @@ ldns_status ldns_str2rdf_loc(ldns_rdf **, const uint8_t*); ldns_status ldns_str2rdf_wks(ldns_rdf **, const uint8_t*); ldns_status ldns_str2rdf_nsap(ldns_rdf **, const uint8_t*); +ldns_status ldns_str2rdf_dname(ldns_dname **, const uint8_t*); + #endif diff --git a/net.c b/net.c index 023f6256..e8c93774 100644 --- a/net.c +++ b/net.c @@ -36,31 +36,6 @@ ldns_send_pkt(ldns_resolver *r, ldns_pkt *query) { /* the resolver has a lot of flags, * make one giant switch the handles them */ - uint8_t config; - - struct sockaddr_in src, dest; - int sockfd; - - /* binary */ - config = ldns_resolver_ip6(r) * 2 + - ldns_resolver_usevc(r); - - switch(config) { - case 0: - /* ip4/udp */ - src.sin_family = AF_INET; - src.sin_addr.s_addr(in_addr_t)htonl(INADDR_ANY); - break; - case 1: - /* ip4/tcp */ - break; - case 2: - /* ip6/udp */ - break; - case 3: - /* ip6/tcp */ - break; - } return NULL; } @@ -124,3 +99,50 @@ ldns_sendbuf_axfr(ldns_buffer *buf, int *sockfd, struct sockaddr *dest) { return NULL; } + +/** + * Send to ptk to the nameserver at ipnumber. Return the data + * as a ldns_pkt + * \param[in] resolver to use + * \param[in] query to send + * \return the pkt received from the nameserver + */ +ldns_pkt * +ldns_send(ldns_resolver *r, ldns_pkt *query_pkt) +{ + uint8_t flags; + + /* create a socket + * create a binary packet + * call the lowlevel send stuff + * and fire it off + */ + /* try all nameservers in sequence */ + + switch (flags) { + case 0 /*LDNS_RESOLVER_FL_UDP:*/: + + + + break; + case 1: /*LDNS_RESOLVER_FL_TCP:*/ + break; + } +} + + +#if 0 +/** + */ +ldns_buffer * +ldns_send_udp(ldns_buffer *qbin, const struct sockaddr *from, socklen_t fromlen, + const struct sockaddr *to, socklen_t tolen) +{ + int sockfd; + + sockfd = socket( + + + +} +#endif diff --git a/rdata.c b/rdata.c index 0b5bf442..c212404b 100644 --- a/rdata.c +++ b/rdata.c @@ -141,11 +141,49 @@ ldns_rdf_free(ldns_rdf *rd) ldns_dname * ldns_dname_new_frm_str(const char *str) { - ldns_rdf *rd; - if (ldns_str2rdf_dname(&rd, (const uint8_t*) str) != LDNS_STATUS_OK) { + ldns_dname *d; + if (ldns_str2rdf_dname(&d, (const uint8_t*) str) != LDNS_STATUS_OK) { return NULL ; } - return rd; + return d; +} + +/** + * Allocate a new dname structure and fill it. + * This function _does_ copy the contents from + * the buffer, unlinke ldns_rdf_new() + * \param[in] s size of the buffer + * \param[in] buf pointer to the buffer to be copied + * \return the new dname structure or NULL on failure + */ +ldns_dname * +ldns_dname_new_frm_data(uint16_t s, void *buf) +{ + ldns_dname *d; + d = MALLOC(ldns_dname); + if (!d) { + return NULL; + } + d->_data = XMALLOC(uint8_t, s); + if (!d->_data) { + return NULL; + } + d->_size = s; + memcpy(d->_data, buf, s); + return d; +} + +/** + * free a rdf structure _and_ free the + * data. rdf should be created with _new_frm_data + * \param[in] rd the rdf structure to be freed + * \return void + */ +void +ldns_dname_free_data(ldns_dname *d) +{ + FREE(d->_data); + FREE(d); } @@ -165,7 +203,7 @@ ldns_rdf_new_frm_str(const char *str, ldns_rdf_type t) case LDNS_RDF_TYPE_NONE: break; case LDNS_RDF_TYPE_DNAME: - stat = ldns_str2rdf_dname(&rd, (const uint8_t*) str); + printf("use the ldns_dname type!!\n\n"); break; case LDNS_RDF_TYPE_INT8: stat = ldns_str2rdf_int8(&rd, (const uint8_t*) str); diff --git a/str2host.c b/str2host.c index ec2201e4..e3d5da5c 100644 --- a/str2host.c +++ b/str2host.c @@ -144,7 +144,7 @@ ldns_str2rdf_int8(ldns_rdf **rd, const uint8_t *bytestr) * label_chars2 is used for debugging. TODO: remove */ ldns_status -ldns_str2rdf_dname(ldns_rdf **rd, const uint8_t* str) +ldns_str2rdf_dname(ldns_dname **d, const uint8_t* str) { unsigned int label_chars; unsigned int label_chars2; @@ -193,10 +193,8 @@ ldns_str2rdf_dname(ldns_rdf **rd, const uint8_t* str) q += (label_chars + 1); *q = '\00'; /* end the string */ - /* s - buf_str works because no magic is done - * in the above for-loop - */ - *rd = ldns_rdf_new_frm_data((s - buf_str + 1) , LDNS_RDF_TYPE_DNAME, buf); + /* s - buf_str works because no magic is done * in the above for-loop */ + *d = ldns_dname_new_frm_data((s - buf_str + 1) , buf); return LDNS_STATUS_OK; }