[Unbound-users] C based code sample for DNSMessage construction
Seetharaman Ramasubramani
mani at powercloudsystems.com
Wed Feb 27 01:02:44 UTC 2013
Hi,
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:
#create instance of DNS message (packet) with given parameters
msg = DNSMessage(qstate.qinfo.qname_str, RR_TYPE_A,
RR_CLASS_IN, PKT_QR | PKT_RA | PKT_AA)
#append RR
if (qstate.qinfo.qtype == RR_TYPE_A) or (qstate.qinfo.qtype ==
RR_TYPE_ANY):
msg.answer.append("%s 10 IN A 127.0.0.1" %
qstate.qinfo.qname_str)
#set qstate.return_msg
if not msg.set_return_msg(qstate):
qstate.ext_state[id] = MODULE_ERROR
return True
#we don't need validation, result is valid
qstate.return_msg.rep.security = 2
qstate.return_rcode = RCODE_NOERROR
qstate.ext_state[id] = MODULE_FINISHED
Thanks much
Mani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nlnetlabs.nl/pipermail/unbound-users/attachments/20130226/202a2221/attachment.htm>
More information about the Unbound-users
mailing list