Hi,<div> <br clear="all"><div> I am build C based code modules to be plugged into Unbound. I am looking for code samples in C to construct DNS Message responses to queries. Basically, code to do something very similar to the python code in examples/resgen.py,as below:</div>
<div><br></div><div><div> #create instance of DNS message (packet) with given parameters</div><div> msg = DNSMessage(qstate.qinfo.qname_str, RR_TYPE_A, RR_CLASS_IN, PKT_QR | PKT_RA | PKT_AA)</div><div>
#append RR</div><div> if (qstate.qinfo.qtype == RR_TYPE_A) or (qstate.qinfo.qtype == RR_TYPE_ANY):</div><div> msg.answer.append("%s 10 IN A 127.0.0.1" % qstate.qinfo.qname_str)</div>
<div> #set qstate.return_msg</div><div> if not msg.set_return_msg(qstate):</div><div> qstate.ext_state[id] = MODULE_ERROR</div><div> return True</div><div><br></div><div>
#we don't need validation, result is valid</div><div> qstate.return_msg.rep.security = 2</div><div><br></div><div> qstate.return_rcode = RCODE_NOERROR</div><div> qstate.ext_state[id] = MODULE_FINISHED</div>
</div><div><br></div><div>Thanks much</div><div>Mani</div>
</div>