Пример #1
0
void
freearea(Area **l)
{
	Area *s;

	while(s = *l){
		*l = s->next;
		rrfree(s->soarr);
		free(s);
	}
}
Пример #2
0
static void
dnzone(DNSmsg *reqp, DNSmsg *repp, Request *req)
{
	DN *dp, *ndp;
	RR r, *rp;
	int h, depth, found, nlen;

	memset(repp, 0, sizeof(*repp));
	repp->id = reqp->id;
	repp->qd = reqp->qd;
	reqp->qd = reqp->qd->next;
	repp->qd->next = 0;
	repp->flags = Fauth | Fresp | Oquery;
	if(!norecursion)
		repp->flags |= Fcanrec;
	dp = repp->qd->owner;

	/* send the soa */
	repp->an = rrlookup(dp, Tsoa, NOneg);
	reply(1, repp, req);
	if(repp->an == 0)
		goto out;
	rrfreelist(repp->an);
	repp->an = nil;

	nlen = strlen(dp->name);

	/* construct a breadth-first search of the name space (hard with a hash) */
	repp->an = &r;
	for(depth = numelem(dp->name); ; depth++){
		found = 0;
		for(h = 0; h < HTLEN; h++)
			for(ndp = ht[h]; ndp; ndp = ndp->next)
				if(inzone(ndp, dp->name, nlen, depth)){
					for(rp = ndp->rr; rp; rp = rp->next){
						/*
						 * there shouldn't be negatives,
						 * but just in case.
						 * don't send any soa's,
						 * ns's are enough.
						 */
						if (rp->negative ||
						    rp->type == Tsoa)
							continue;
						r = *rp;
						r.next = 0;
						reply(1, repp, req);
					}
					found = 1;
				}
		if(!found)
			break;
	}

	/* resend the soa */
	repp->an = rrlookup(dp, Tsoa, NOneg);
	reply(1, repp, req);
	rrfreelist(repp->an);
	repp->an = nil;
out:
	rrfree(repp->qd);
	repp->qd = nil;
}
Пример #3
0
Файл: dns.c Проект: npe9/harvey
static void
fmtrr(Msg *m, RR **rrp, int quest)
{
	Txt *t;
	RR *rr;

	rr = *rrp;
	if(rr == nil)
		return;
	*rrp = rr->next;

	m->p = seprint(m->p, m->e, "%s name=%s ttl=%lud",
		rrtypestr(rr->type),
		rr->owner->name, rr->ttl);
	if(!quest)
	switch(rr->type){
	default:
		break;
	case Thinfo:
		m->p = seprint(m->p, m->e, " cpu=%s os=%s",
			rr->cpu->name, rr->os->name);
		break;
	case Tcname:
	case Tmb:
	case Tmd:
	case Tmf:
	case Tns:
		m->p = seprint(m->p, m->e, " host=%s", rr->host->name);
		break;
	case Tmg:
	case Tmr:
		m->p = seprint(m->p, m->e, " mb=%s", rr->mb->name);
		break;
	case Tminfo:
		m->p = seprint(m->p, m->e, " rmb=%s", rr->rmb->name);
		m->p = seprint(m->p, m->e, " mb=%s", rr->mb->name);
		break;
	case Tmx:
		m->p = seprint(m->p, m->e, " pref=%lud", rr->pref);
		m->p = seprint(m->p, m->e, " host=%s", rr->host->name);
		break;
	case Ta:
	case Taaaa:
		m->p = seprint(m->p, m->e, " ip=%s", rr->ip->name);
		break;
	case Tptr:
		m->p = seprint(m->p, m->e, " ptr=%s", rr->ptr->name);
		break;
	case Tsoa:
		m->p = seprint(m->p, m->e, " host=%s", rr->host->name);
		m->p = seprint(m->p, m->e, " rmb=%s", rr->rmb->name);
		m->p = seprint(m->p, m->e, " soa.serial=%lud", rr->soa->serial);
		m->p = seprint(m->p, m->e, " soa.refresh=%lud", rr->soa->refresh);
		m->p = seprint(m->p, m->e, " soa.retry=%lud", rr->soa->retry);
		m->p = seprint(m->p, m->e, " soa.expire=%lud", rr->soa->expire);
		m->p = seprint(m->p, m->e, " soa.minttl=%lud", rr->soa->minttl);
		break;
	case Ttxt:
		for(t=rr->txt; t; t=t->next)
			m->p = seprint(m->p, m->e, " txt=%q", t->p);
		break;
	case Tnull:
		m->p = seprint(m->p, m->e, " null=%.*H",
			rr->null->dlen, rr->null->data);
		break;
	case Trp:
		m->p = seprint(m->p, m->e, " rmb=%s", rr->rmb->name);
		m->p = seprint(m->p, m->e, " rp=%s", rr->rp->name);
		break;
	case Tkey:
		m->p = seprint(m->p, m->e, " flags=%d proto=%d alg=%d data=%.*H",
			rr->key->flags, rr->key->proto, rr->key->alg,
			rr->key->dlen, rr->key->data);
		break;
	case Tsig:
		m->p = seprint(m->p, m->e,
" type=%d alg=%d labels=%d ttl=%lud exp=%lud incep=%lud tag=%d signer=%s data=%.*H",
			rr->sig->type, rr->sig->alg, rr->sig->labels,
			rr->sig->ttl, rr->sig->exp, rr->sig->incep, rr->sig->tag,
			rr->sig->signer->name, rr->sig->dlen, rr->sig->data);
		break;
	case Tcert:
		m->p = seprint(m->p, m->e, " type=%d tag=%d alg=%d data=%.*H",
			rr->cert->type, rr->cert->tag, rr->cert->alg,
			rr->cert->dlen, rr->cert->data);
		break;
	}
	rrfree(rr);
}