Пример #1
0
/**
 * Associate a pre-existing LDAP DB instance with a new DNS zone.
 *
 * @warning This is a hack.
 *
 * Normally, an empty database is created by dns_db_create() call during
 * dns_zone_load().
 *
 * In our case, we need to create and populate databases on-the-fly
 * as we process data from LDAP.
 * We create an empty LDAP DB (which encapsulates internal RBT DB)
 * for each zone when the zone is being added to zone_register.
 *
 * The database in zone register is modified on-the-fly and subsequent
 * dns_db_create() call associates this populated database with the DNS zone.
 *
 * This allows us to call dns_zone_load() later when all the data are in place,
 * so dns_zone_load() can be postponed until synchronization state sync_finish
 * is reached.
 *
 * @param[in] argv [0] is database instance name
 */
isc_result_t
ldapdb_associate(isc_mem_t *mctx, dns_name_t *name, dns_dbtype_t type,
		 dns_rdataclass_t rdclass, unsigned int argc, char *argv[],
		 void *driverarg, dns_db_t **dbp) {

	isc_result_t result;
	ldap_instance_t *ldap_inst = NULL;
	zone_register_t *zr = NULL;

	UNUSED(driverarg); /* Currently we don't need any data */

	REQUIRE(ISCAPI_MCTX_VALID(mctx));
	REQUIRE(argc == LDAP_DB_ARGC);
	REQUIRE(type == LDAP_DB_TYPE);
	REQUIRE(rdclass == LDAP_DB_RDATACLASS);
	REQUIRE(dbp != NULL && *dbp == NULL);

	CHECK(manager_get_ldap_instance(argv[0], &ldap_inst));
	zr = ldap_instance_getzr(ldap_inst);
	if (zr == NULL)
		CLEANUP_WITH(ISC_R_NOTFOUND);

	CHECK(zr_get_zone_dbs(zr, name, dbp, NULL));

cleanup:
	return result;
}
Пример #2
0
void isc_mem_detach (isc_mem_t ** mctxp)
{
    REQUIRE (mctxp != NULL && ISCAPI_MCTX_VALID (*mctxp));

    (*mctxp)->methods->detach (mctxp);

    ENSURE (*mctxp == NULL);
}
Пример #3
0
void isc_mem_attach (isc_mem_t * source, isc_mem_t ** targetp)
{
    REQUIRE (ISCAPI_MCTX_VALID (source));
    REQUIRE (targetp != NULL && *targetp == NULL);

    source->methods->attach (source, targetp);

    ENSURE (*targetp == source);
}
Пример #4
0
void isc__mem_putanddetach (isc_mem_t ** mctxp, void *ptr, size_t size FLARG)
{
    REQUIRE (mctxp != NULL && ISCAPI_MCTX_VALID (*mctxp));

    (*mctxp)->methods->memputanddetach (mctxp, ptr, size FLARG_PASS);

    /*
     * XXX: We cannot always ensure *mctxp == NULL here
     * (see lib/isc/mem.c).
     */
}
Пример #5
0
void *isc__mem_reallocate (isc_mem_t * mctx, void *ptr, size_t size FLARG)
{
    REQUIRE (ISCAPI_MCTX_VALID (mctx));

    return (mctx->methods->memreallocate (mctx, ptr, size FLARG_PASS));
}
Пример #6
0
void isc__mem_put (isc_mem_t * mctx, void *ptr, size_t size FLARG)
{
    REQUIRE (ISCAPI_MCTX_VALID (mctx));

    mctx->methods->memput (mctx, ptr, size FLARG_PASS);
}
Пример #7
0
void *isc__mem_get (isc_mem_t * mctx, size_t size FLARG)
{
    REQUIRE (ISCAPI_MCTX_VALID (mctx));

    return (mctx->methods->memget (mctx, size FLARG_PASS));
}