]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
use ldns_dname where appropiate
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 27 Jan 2005 12:21:02 +0000 (12:21 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 27 Jan 2005 12:21:02 +0000 (12:21 +0000)
some other, non-working network changes

doc/overview
ldns/str2host.h
net.c
rdata.c
str2host.c

index 56c79efb6789ded964b0f65ee6bf3cd924271b84..6bfcc638b9526b460e7d33a82d0a9d51ce126d76 100644 (file)
@@ -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
index 3fbc13e5b982f93bb4d01d607af03a414a3ae3e1..2a89079bf2fcccbde173d7b0706cc6d1d03a38c2 100644 (file)
@@ -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 023f6256592a5fbe03cfed5659dd2c1ce7307e62..e8c93774255f2dc97b0cb95761699b1d993b0fee 100644 (file)
--- 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 0b5bf4429cf8df618c3e7119a04250a9e4a0f195..c212404bb891fd67b499c8afd58d4856522a02b6 100644 (file)
--- 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);
index ec2201e4dbb9a552a766dadfe35cf1e8f678fd44..e3d5da5cb8038bf0fc2afb2b9ddd5a4bbd7d94f0 100644 (file)
@@ -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;
 }