X-Git-Url: https://git.distorted.org.uk/~mdw/adns/blobdiff_plain/2c6eb096dd80e37c12ec5a301b771ff011fc00ce..8de0fa76b3e27b4a96db5c77415962117650afa7:/src/query.c?ds=sidebyside diff --git a/src/query.c b/src/query.c index 4b24a30..a3ce68d 100644 --- a/src/query.c +++ b/src/query.c @@ -5,12 +5,11 @@ * - query submission and cancellation (user-visible and internal) */ /* - * This file is - * Copyright (C) 1997-2000 Ian Jackson - * - * It is part of adns, which is - * Copyright (C) 1997-2000 Ian Jackson - * Copyright (C) 1999-2000 Tony Finch + * This file is part of adns, which is + * Copyright (C) 1997-2000,2003,2006 Ian Jackson + * Copyright (C) 1999-2000,2003,2006 Tony Finch + * Copyright (C) 1991 Massachusetts Institute of Technology + * (See the file INSTALL for full details.) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,21 +108,67 @@ static void query_submit(adns_state ads, adns_query qu, adns__query_send(qu,now); } +adns_status adns__ckl_hostname(adns_state ads, adns_queryflags flags, + union checklabel_state *cls, + qcontext *ctx, int labnum, + const char *label, int lablen) +{ + int i, c; + + if (flags & adns_qf_quoteok_query) return adns_s_ok; + for (i=0; i= 0); + err= typei->checklabel(ads,flags, &cls,ctx, + labnum++, dgram+labstart,lablen); + if (err) return err; + } while (lablen); + return adns_s_ok; +} + adns_status adns__internal_submit(adns_state ads, adns_query *query_r, const typeinfo *typei, vbuf *qumsg_vb, int id, adns_queryflags flags, struct timeval now, - const qcontext *ctx) { + qcontext *ctx) { adns_query qu; + adns_status err; + err= check_domain_name(ads, flags,ctx,typei, qumsg_vb->buf,qumsg_vb->used); + if (err) goto x_err; qu= query_alloc(ads,typei,typei->typekey,flags,now); - if (!qu) { adns__vbuf_free(qumsg_vb); return adns_s_nomemory; } + if (!qu) { err = adns_s_nomemory; goto x_err; } *query_r= qu; memcpy(&qu->ctx,ctx,sizeof(qu->ctx)); query_submit(ads,qu, typei,qumsg_vb,id,flags,now); return adns_s_ok; + +x_err: + adns__vbuf_free(qumsg_vb); + return err; } static void query_simple(adns_state ads, adns_query qu, @@ -146,6 +191,9 @@ static void query_simple(adns_state ads, adns_query qu, } } + stat= check_domain_name(ads, flags,&qu->ctx,typei, qu->vb.buf,qu->vb.used); + if (stat) { adns__query_fail(qu,stat); return; } + vb_new= qu->vb; adns__vbuf_init(&qu->vb); query_submit(ads,qu, typei,&vb_new,id, flags,now); @@ -231,7 +279,8 @@ int adns_submit(adns_state ads, qu->ctx.ext= context; qu->ctx.callback= 0; - memset(&qu->ctx.info,0,sizeof(qu->ctx.info)); + memset(&qu->ctx.pinfo,0,sizeof(qu->ctx.pinfo)); + memset(&qu->ctx.tinfo,0,sizeof(qu->ctx.tinfo)); *query_r= qu;