static void set_previous_owner(struct state_pretty_rr *state, const dname_type *dname) { region_free_all(state->previous_owner_region); state->previous_owner = dname_copy(state->previous_owner_region, dname); state->previous_owner_origin = dname_origin( state->previous_owner_region, state->previous_owner); }
int mesg_make_query (u_char *qname, uint16_t qtype, uint16_t qclass, uint32_t id, int rd, u_char *buf, int buflen) { char *fn = "mesg_make_query()"; u_char *ucp; int i, written_len; Mesg_Hdr *hdr; if (T.debug > 4) syslog (LOG_DEBUG, "%s: (qtype: %s, id: %d): start", fn, string_rtype (qtype), id); hdr = (Mesg_Hdr *) buf; /* write header */ hdr->id = id; hdr->opcode = OP_QUERY; hdr->rcode = RC_OK; hdr->rd = rd; hdr->qr = hdr->aa = hdr->tc = hdr->ra = hdr->zero = 0; hdr->qdcnt = ntohs (1); hdr->ancnt = hdr->nscnt = hdr->arcnt = ntohs (0); written_len = sizeof (Mesg_Hdr); ucp = (u_char *) (hdr + 1); /* write qname */ if (T.debug > 4) syslog (LOG_DEBUG, "%s: qname offset = %d", fn, (int)(ucp - buf)); i = dname_copy (qname, ucp, buflen - written_len); if (i < 0) return -1; written_len += i; ucp += i; /* write qtype / qclass */ if (T.debug > 4) syslog (LOG_DEBUG, "%s: qtype/qclass offset = %d", fn, (int)(ucp - buf)); written_len += sizeof (uint16_t) * 2; if (written_len > buflen) return -1; PUTSHORT (qtype, ucp); PUTSHORT (qclass, ucp); return written_len; }
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"); }