コード例 #1
0
ファイル: network.c プロジェクト: gitter-badger/knot-resolver
void network_deinit(struct network *net)
{
	if (net != NULL) {
		map_walk(&net->endpoints, visit_key, close_endpoint);
		map_walk(&net->endpoints, free_key, 0);
		map_clear(&net->endpoints);
	}
}
コード例 #2
0
ファイル: bindings.c プロジェクト: PaulosV/knot-resolver
/** List active endpoints. */
static int net_list(lua_State *L)
{
    struct engine *engine = engine_luaget(L);
    lua_newtable(L);
    map_walk(&engine->net.endpoints, net_list_add, L);
    return 1;
}
コード例 #3
0
ファイル: nsrep.c プロジェクト: gitter-badger/knot-resolver
int kr_nsrep_elect(struct kr_query *qry, struct kr_context *ctx)
{
	if (!qry || !ctx) {
		return kr_error(EINVAL);
	}

	struct kr_nsrep *ns = &qry->ns;
	ELECT_INIT(ns, ctx);
	return map_walk(&qry->zone_cut.nsset, eval_nsrep, qry);
}
コード例 #4
0
ファイル: validate.c プロジェクト: Karm/knot-resolver
static int validate_section(kr_rrset_validation_ctx_t *vctx, knot_mm_t *pool)
{
	if (!vctx) {
		return kr_error(EINVAL);
	}

	const knot_pktsection_t *sec = knot_pkt_section(vctx->pkt,
							vctx->section_id);
	if (!sec) {
		return kr_ok();
	}

	int ret = kr_ok();

	map_t stash = map_make();
	stash.malloc = (map_alloc_f) mm_alloc;
	stash.free = (map_free_f) mm_free;
	stash.baton = pool;

	/* Determine RR types contained in the section. */
	for (unsigned i = 0; i < sec->count; ++i) {
		const knot_rrset_t *rr = knot_pkt_rr(sec, i);
		if (rr->type == KNOT_RRTYPE_RRSIG) {
			continue;
		}
		if ((rr->type == KNOT_RRTYPE_NS) && (vctx->section_id == KNOT_AUTHORITY)) {
			continue;
		}
		/* Only validate answers from current cut, records above the cut are stripped. */
		if (!knot_dname_in(vctx->zone_name, rr->owner)) {
			continue;
		}
		ret = kr_rrmap_add(&stash, rr, 0, pool);
		if (ret != 0) {
			goto fail;
		}
	}

	/* Can't use qry->zone_cut.name directly, as this name can
	 * change when updating cut information before validation.
	 */
	vctx->zone_name = vctx->keys ? vctx->keys->owner  : NULL;

	ret = map_walk(&stash, &validate_rrset, vctx);
	if (ret != 0) {
		return ret;
	}
	ret = vctx->result;

fail:
	return ret;
}