chiark / gitweb /
WIP dns transport
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Jul 2011 23:20:13 +0000 (00:20 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Aug 2011 15:44:05 +0000 (16:44 +0100)
dns-transp-common.c
dns-transp-common.h

index 59f739a0a6e4d392fc8565892887fa256161e8dd..2505828f42331434fd968ac12134a7101969589f 100644 (file)
@@ -169,6 +169,7 @@ static void inputchar(struct dnsbitdec *bd) {
     int ch=*--(bd->in);
     bd->pending <<= 8;
     bd->pending |= ch; /* already decoded */
+    bd->npending += 5;
 }
 uint32_t dnsdomaindec_getbits(struct dnsbitdec *bd, int nbits)
 {
@@ -189,5 +190,17 @@ uint32_t dnsdomaindec_getu32(struct dnsbitdec *bd)
 }
 int dnsbitdec_restbytes(struct dnsbitdec *bd, uint8_t outbuf[MAX_DOMAIN_BYTES])
 {
+    uint8_t *out;
     for (;;) {
-       
+       if (bd->npending >= 8) {
+           *out++ = bd->pending;
+           bd->pending >>= 8;
+           bd->npending -= 8;
+       }
+       if (bd->in == bd->databuf) {
+           /* that's all the input */
+           return out - outbuf;
+       }
+       inputchar(bd);
+    }
+}
index a7154271f29a605eb3127c01c702aa064436d59b..d2ad5aa5a730717b113eb72073356ee06ffdb7ec 100644 (file)
@@ -29,3 +29,4 @@ uint8_t *dnsbitenc_getresult(struct dnsbitenc *be);
     /* returns pointer into caller-supplied buffer; we have used
      * bytes from the result to the end (so the caller needs to remember
      * the buffer len to know what the encoded length is */
+fixme needs to add mylabels too