From: Ian Jackson Date: Sat, 30 Jul 2011 23:20:13 +0000 (+0100) Subject: WIP dns transport X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=33731fa899d333a8a36301ed48ce10bccc728415;p=secnet.git WIP dns transport --- diff --git a/dns-transp-common.c b/dns-transp-common.c index 59f739a..2505828 100644 --- a/dns-transp-common.c +++ b/dns-transp-common.c @@ -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); + } +} diff --git a/dns-transp-common.h b/dns-transp-common.h index a715427..d2ad5aa 100644 --- a/dns-transp-common.h +++ b/dns-transp-common.h @@ -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