Answering MX queries from withing a module
Hi, I am trying to resolve and answer mx packets in my knot-resolver module.
I have c++ data structure which holds records. Resolving is not a big deal, just going through structure and selecting records that I want to return. Answering the packet on the other hand is problematic in this case. Let's pretend resolving was correct and returned string as I am simulating in following code.
"replaceDots" function is replacing dots with numbers representing character quantity between dots as is needed for domain resolving - this is working correctly.
fullName = replaceDots("mx1.random.cz.tld");
uint8_t *domain = (unsigned char*)fullName.c_str();
knot_dname_t *qname = knot_dname_copy(qry->sname, &pkt->mm);
knot_rrset_t rr;
At this point I thought that when I replace RRTYPE constant, knot would understand and make MX-like answer
knot_rrset_init(&rr, qname, KNOT_RRTYPE_MX, KNOT_CLASS_IN);
knot_rrset_add_rdata(&rr, domain, knot_dname_size(domain), 0, &pkt->mm);
return put_answer(pkt, &rr);
A, AAAA, domain name resolving is working completely correctly in my module (combined C and C++ code), but in this case (MX resolve) "knot_pkt_put" function in "put_answer" function is somehow always failing.
So finally, I would like to ask if there's way to answer these MX requests (shortly + correctly) like this and if is knot able to do so.
(knot 2.1.0, knot-resolver 1.0.0 - module is for private network so don't bother with security and stuff.. Plus I'm working on SUSE 42.2 machine and there's no way to obtain newer versions.)