From 33731fa899d333a8a36301ed48ce10bccc728415 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 31 Jul 2011 00:20:13 +0100 Subject: [PATCH] WIP dns transport --- dns-transp-common.c | 15 ++++++++++++++- dns-transp-common.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) 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 -- 2.30.2