void gdnsd_result_add_cname(dyn_result_t* result, const uint8_t* dname, const uint8_t* origin) { dmn_assert(result); dmn_assert(dname); dmn_assert(origin); dmn_assert(dname_status(dname) != DNAME_INVALID); dmn_assert(dname_status(origin) == DNAME_VALID); dmn_assert(!result->is_cname); dmn_assert(!result->count_v4); dmn_assert(!result->count_v6); result->is_cname = true; dname_copy(result->storage, dname); if(dname_is_partial(result->storage)) dname_cat(result->storage, origin); dmn_assert(dname_status(result->storage) == DNAME_VALID); }
int plugin_static_map_res(const char* resname, const uint8_t* origin) { if(resname) { for(unsigned i = 0; i < num_resources; i++) { if(!strcmp(resname, resources[i].name)) { if(resources[i].is_addr) return (int)i; if(!origin) map_res_err("plugin_static: CNAME resource '%s' cannot be used for a DYNA record", resources[i].name); if(dname_is_partial(resources[i].dname)) { uint8_t dnbuf[256]; dname_copy(dnbuf, resources[i].dname); dname_status_t status = dname_cat(dnbuf, origin); if(status != DNAME_VALID) map_res_err("plugin_static: CNAME resource '%s' (configured with partial domainname '%s') creates an invalid domainname when used at origin '%s'", resources[i].name, logf_dname(resources[i].dname), logf_dname(origin)); } return (int)i; } } map_res_err("plugin_static: Unknown resource '%s'", resname); } map_res_err("plugin_static: resource name required"); }