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 -
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
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*);
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
{
/* 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;
}
{
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
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);
}
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);
* 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;
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;
}