aboutsummaryrefslogtreecommitdiff
path: root/pythonmod
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2021-08-16 23:55:17 +0000
committerCy Schubert <cy@FreeBSD.org>2021-08-16 23:57:03 +0000
commit625f1c1312fb7defbd148c8ba121a0cf058707ef (patch)
tree31510b9372850c8a8dd3e0a8dac37308308d8429 /pythonmod
parentd60fa10fd872db7e3d8cb1e161cfdae026c43b14 (diff)
Diffstat (limited to 'pythonmod')
-rw-r--r--pythonmod/doc/modules/functions.rst14
-rw-r--r--pythonmod/interface.i41
-rw-r--r--pythonmod/pythonmod.c58
-rw-r--r--pythonmod/pythonmod_utils.c211
-rw-r--r--pythonmod/pythonmod_utils.h52
5 files changed, 232 insertions, 144 deletions
diff --git a/pythonmod/doc/modules/functions.rst b/pythonmod/doc/modules/functions.rst
index 333f696b814f..951a17f948c7 100644
--- a/pythonmod/doc/modules/functions.rst
+++ b/pythonmod/doc/modules/functions.rst
@@ -92,7 +92,7 @@ Inplace callbacks
.. function:: inplace_cb_reply(qinfo, qstate, rep, rcode, edns, opt_list_out, region, \*\*kwargs)
Function prototype for callback functions used in
- `register_inplace_cb_reply`_, `register_inplace_cb_reply_cache`_,
+ `register_inplace_cb_reply`, `register_inplace_cb_reply_cache`,
`register_inplace_cb_reply_local` and `register_inplace_cb_reply_servfail`.
:param qinfo: :class:`query_info`
@@ -109,7 +109,7 @@ Inplace callbacks
.. function:: inplace_cb_query(qinfo, flags, qstate, addr, zone, region)
Function prototype for callback functions used in
- `register_inplace_cb_query`_.
+ `register_inplace_cb_query`.
:param qinfo: :class:`query_info`
:param flags: query flags (integer)
@@ -122,7 +122,7 @@ Inplace callbacks
Register py_cb as an inplace reply callback function.
- :param py_cb: Python function that follows `inplace_cb_reply`_'s prototype. **Must** be callable.
+ :param py_cb: Python function that follows `inplace_cb_reply`'s prototype. **Must** be callable.
:param env: :class:`module_env`
:param id: Module ID.
:return: True on success, False otherwise
@@ -132,7 +132,7 @@ Inplace callbacks
Register py_cb as an inplace reply_cache callback function.
- :param py_cb: Python function that follows `inplace_cb_reply`_'s prototype. **Must** be callable.
+ :param py_cb: Python function that follows `inplace_cb_reply`'s prototype. **Must** be callable.
:param env: :class:`module_env`
:param id: Module ID.
:return: True on success, False otherwise
@@ -142,7 +142,7 @@ Inplace callbacks
Register py_cb as an inplace reply_local callback function.
- :param py_cb: Python function that follows `inplace_cb_reply`_'s prototype. **Must** be callable.
+ :param py_cb: Python function that follows `inplace_cb_reply`'s prototype. **Must** be callable.
:param env: :class:`module_env`
:param id: Module ID.
:return: True on success, False otherwise
@@ -152,7 +152,7 @@ Inplace callbacks
Register py_cb as an inplace reply_servfail callback function.
- :param py_cb: Python function that follows `inplace_cb_reply`_'s prototype. **Must** be callable.
+ :param py_cb: Python function that follows `inplace_cb_reply`'s prototype. **Must** be callable.
:param env: :class:`module_env`
:param id: Module ID.
:return: True on success, False otherwise
@@ -162,7 +162,7 @@ Inplace callbacks
Register py_cb as an inplace query callback function.
- :param py_cb: Python function that follows `inplace_cb_query`_'s prototype. **Must** be callable.
+ :param py_cb: Python function that follows `inplace_cb_query`'s prototype. **Must** be callable.
:param env: :class:`module_env`
:param id: Module ID.
:return: True on success, False otherwise
diff --git a/pythonmod/interface.i b/pythonmod/interface.i
index 5dae04aa404b..ce7dcde7173c 100644
--- a/pythonmod/interface.i
+++ b/pythonmod/interface.i
@@ -1546,7 +1546,7 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
{
PyObject *func, *py_edns, *py_qstate, *py_opt_list_out, *py_qinfo;
PyObject *py_rep, *py_repinfo, *py_region;
- PyObject *py_args, *py_kwargs, *result;
+ PyObject *py_args = NULL, *py_kwargs = NULL, *result = NULL;
int res = 0;
double py_start_time = ((double)start_time->tv_sec) + ((double)start_time->tv_usec) / 1.0e6;
@@ -1561,11 +1561,20 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
py_rep = SWIG_NewPointerObj((void*) rep, SWIGTYPE_p_reply_info, 0);
py_repinfo = SWIG_NewPointerObj((void*) repinfo, SWIGTYPE_p_comm_reply, 0);
py_region = SWIG_NewPointerObj((void*) region, SWIGTYPE_p_regional, 0);
- py_args = Py_BuildValue("(OOOiOOO)", py_qinfo, py_qstate, py_rep,
- rcode, py_edns, py_opt_list_out, py_region);
- py_kwargs = Py_BuildValue("{s:O,s:d}", "repinfo", py_repinfo, "start_time",
- py_start_time);
- result = PyObject_Call(func, py_args, py_kwargs);
+ if(py_qinfo && py_qstate && py_rep && py_edns && py_opt_list_out
+ && py_region && py_repinfo) {
+ py_args = Py_BuildValue("(OOOiOOO)", py_qinfo, py_qstate, py_rep,
+ rcode, py_edns, py_opt_list_out, py_region);
+ py_kwargs = Py_BuildValue("{s:O,s:d}", "repinfo", py_repinfo, "start_time",
+ py_start_time);
+ if(py_args && py_kwargs) {
+ result = PyObject_Call(func, py_args, py_kwargs);
+ } else {
+ log_err("pythonmod: malloc failure in python_inplace_cb_reply_generic");
+ }
+ } else {
+ log_err("pythonmod: malloc failure in python_inplace_cb_reply_generic");
+ }
Py_XDECREF(py_edns);
Py_XDECREF(py_qstate);
Py_XDECREF(py_opt_list_out);
@@ -1624,6 +1633,7 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
{
int res = 0;
PyObject *func = python_callback;
+ PyObject *py_args = NULL, *py_kwargs = NULL, *result = NULL;
PyGILState_STATE gstate = PyGILState_Ensure();
@@ -1632,12 +1642,19 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
PyObject *py_addr = SWIG_NewPointerObj((void *) addr, SWIGTYPE_p_sockaddr_storage, 0);
PyObject *py_zone = PyBytes_FromStringAndSize((const char *)zone, zonelen);
PyObject *py_region = SWIG_NewPointerObj((void*) region, SWIGTYPE_p_regional, 0);
-
- PyObject *py_args = Py_BuildValue("(OiOOOO)", py_qinfo, flags, py_qstate, py_addr, py_zone, py_region);
- PyObject *py_kwargs = Py_BuildValue("{}");
- PyObject *result = PyObject_Call(func, py_args, py_kwargs);
- if (result) {
- res = PyInt_AsLong(result);
+ if(py_qinfo && py_qstate && py_addr && py_zone && py_region) {
+ py_args = Py_BuildValue("(OiOOOO)", py_qinfo, flags, py_qstate, py_addr, py_zone, py_region);
+ py_kwargs = Py_BuildValue("{}");
+ if(py_args && py_kwargs) {
+ result = PyObject_Call(func, py_args, py_kwargs);
+ if (result) {
+ res = PyInt_AsLong(result);
+ }
+ } else {
+ log_err("pythonmod: malloc failure in python_inplace_cb_query_generic");
+ }
+ } else {
+ log_err("pythonmod: malloc failure in python_inplace_cb_query_generic");
}
Py_XDECREF(py_qinfo);
diff --git a/pythonmod/pythonmod.c b/pythonmod/pythonmod.c
index 9006429efff5..4bea54e6aceb 100644
--- a/pythonmod/pythonmod.c
+++ b/pythonmod/pythonmod.c
@@ -245,6 +245,11 @@ cleanup:
/* clear the exception, by not restoring it */
/* Restore the exception state */
/* PyErr_Restore(exc_typ, exc_val, exc_tb); */
+ /* when using PyErr_Restore there is no need to Py_XDECREF for
+ * these 3 pointers. */
+ Py_XDECREF(exc_typ);
+ Py_XDECREF(exc_val);
+ Py_XDECREF(exc_tb);
}
int pythonmod_init(struct module_env* env, int id)
@@ -299,7 +304,10 @@ int pythonmod_init(struct module_env* env, int id)
PyImport_AppendInittab(SWIG_name, (void*)SWIG_init);
#endif
Py_Initialize();
+#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 6)
+ /* initthreads only for python 3.6 and older */
PyEval_InitThreads();
+#endif
SWIG_init();
mainthr = PyEval_SaveThread();
}
@@ -335,7 +343,7 @@ int pythonmod_init(struct module_env* env, int id)
PyFileObject = PyFile_FromString((char*)pe->fname, "r");
script_py = PyFile_AsFile(PyFileObject);
#else
- script_py = _Py_fopen(pe->fname, "r");
+ script_py = fopen(pe->fname, "r");
#endif
if (script_py == NULL)
{
@@ -354,6 +362,8 @@ int pythonmod_init(struct module_env* env, int id)
/* TODO: deallocation of pe->... if an error occurs */
if (PyRun_SimpleFile(script_py, pe->fname) < 0) {
+#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9)
+ /* for python before 3.9 */
log_err("pythonmod: can't parse Python script %s", pe->fname);
/* print the error to logs too, run it again */
fseek(script_py, 0, SEEK_SET);
@@ -369,9 +379,45 @@ int pythonmod_init(struct module_env* env, int id)
/* ignore the NULL return of _node, it is NULL due to the parse failure
* that we are expecting */
(void)PyParser_SimpleParseFile(script_py, pe->fname, Py_file_input);
+#else
+ /* for python 3.9 and newer */
+ char* fstr = NULL;
+ size_t flen = 0;
+ log_err("pythonmod: can't parse Python script %s", pe->fname);
+ /* print the error to logs too, run it again */
+ fseek(script_py, 0, SEEK_END);
+ flen = (size_t)ftell(script_py);
+ fstr = malloc(flen+1);
+ if(!fstr) {
+ log_err("malloc failure to print parse error");
+ PyGILState_Release(gil);
+ fclose(script_py);
+ return 0;
+ }
+ fseek(script_py, 0, SEEK_SET);
+ if(fread(fstr, flen, 1, script_py) < 1) {
+ log_err("file read failed to print parse error: %s: %s",
+ pe->fname, strerror(errno));
+ PyGILState_Release(gil);
+ fclose(script_py);
+ free(fstr);
+ return 0;
+ }
+ fstr[flen] = 0;
+ /* we compile the string, but do not run it, to stop side-effects */
+ /* ignore the NULL return of _node, it is NULL due to the parse failure
+ * that we are expecting */
+ (void)Py_CompileString(fstr, pe->fname, Py_file_input);
+#endif
log_py_err();
PyGILState_Release(gil);
fclose(script_py);
+#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9)
+ /* no cleanup needed for python before 3.9 */
+#else
+ /* cleanup for python 3.9 and newer */
+ free(fstr);
+#endif
return 0;
}
#if PY_MAJOR_VERSION < 3
@@ -520,9 +566,19 @@ void pythonmod_operate(struct module_qstate* qstate, enum module_ev event,
{
/* create qstate */
pq = qstate->minfo[id] = malloc(sizeof(struct pythonmod_qstate));
+ if(!pq) {
+ log_err("pythonmod_operate: malloc failure for qstate");
+ PyGILState_Release(gil);
+ return;
+ }
/* Initialize per query data */
pq->data = PyDict_New();
+ if(!pq->data) {
+ log_err("pythonmod_operate: malloc failure for query data dict");
+ PyGILState_Release(gil);
+ return;
+ }
}
/* Call operate */
diff --git a/pythonmod/pythonmod_utils.c b/pythonmod/pythonmod_utils.c
index 9f7282540e77..21a16bbe85bf 100644
--- a/pythonmod/pythonmod_utils.c
+++ b/pythonmod/pythonmod_utils.c
@@ -5,18 +5,18 @@
* Marek Vavrusa (xvavru00 AT stud.fit.vutbr.cz)
*
* This software is open source.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the organization nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
@@ -56,113 +56,118 @@
#undef _XOPEN_SOURCE
#include <Python.h>
-/* Store the reply_info and query_info pair in message cache (qstate->msg_cache) */
-int storeQueryInCache(struct module_qstate* qstate, struct query_info* qinfo, struct reply_info* msgrep, int is_referral)
+/* Store the reply_info and query_info pair in message cache
+ * (qstate->msg_cache) */
+int storeQueryInCache(struct module_qstate* qstate, struct query_info* qinfo,
+ struct reply_info* msgrep, int is_referral)
{
- if (!msgrep)
- return 0;
-
- if (msgrep->authoritative) /*authoritative answer can't be stored in cache*/
- {
- PyErr_SetString(PyExc_ValueError, "Authoritative answer can't be stored");
- return 0;
- }
+ if (!msgrep)
+ return 0;
+
+ /* authoritative answer can't be stored in cache */
+ if (msgrep->authoritative) {
+ PyErr_SetString(PyExc_ValueError,
+ "Authoritative answer can't be stored");
+ return 0;
+ }
- return dns_cache_store(qstate->env, qinfo, msgrep, is_referral,
- qstate->prefetch_leeway, 0, NULL, qstate->query_flags);
+ return dns_cache_store(qstate->env, qinfo, msgrep, is_referral,
+ qstate->prefetch_leeway, 0, NULL, qstate->query_flags);
}
-/* Invalidate the message associated with query_info stored in message cache */
-void invalidateQueryInCache(struct module_qstate* qstate, struct query_info* qinfo)
-{
- hashvalue_type h;
- struct lruhash_entry* e;
- struct reply_info *r;
- size_t i, j;
-
- h = query_info_hash(qinfo, qstate->query_flags);
- if ((e=slabhash_lookup(qstate->env->msg_cache, h, qinfo, 0)))
- {
- r = (struct reply_info*)(e->data);
- if (r)
- {
- r->ttl = 0;
- if(rrset_array_lock(r->ref, r->rrset_count, *qstate->env->now)) {
- for(i=0; i< r->rrset_count; i++)
- {
- struct packed_rrset_data* data =
- (struct packed_rrset_data*) r->ref[i].key->entry.data;
- if(i>0 && r->ref[i].key == r->ref[i-1].key)
- continue;
-
- data->ttl = r->ttl;
- for(j=0; j<data->count + data->rrsig_count; j++)
- data->rr_ttl[j] = r->ttl;
- }
- rrset_array_unlock(r->ref, r->rrset_count);
- }
+/* Invalidate the message associated with query_info stored in message cache */
+void invalidateQueryInCache(struct module_qstate* qstate,
+ struct query_info* qinfo)
+{
+ hashvalue_type h;
+ struct lruhash_entry* e;
+ struct reply_info *r;
+ size_t i, j;
+
+ h = query_info_hash(qinfo, qstate->query_flags);
+ if ((e=slabhash_lookup(qstate->env->msg_cache, h, qinfo, 0))) {
+ r = (struct reply_info*)(e->data);
+ if (r) {
+ r->ttl = 0;
+ if(rrset_array_lock(r->ref, r->rrset_count, *qstate->env->now)) {
+ for(i=0; i< r->rrset_count; i++) {
+ struct packed_rrset_data* data =
+ (struct packed_rrset_data*) r->ref[i].key->entry.data;
+ if(i>0 && r->ref[i].key == r->ref[i-1].key)
+ continue;
+
+ data->ttl = r->ttl;
+ for(j=0; j<data->count + data->rrsig_count; j++)
+ data->rr_ttl[j] = r->ttl;
+ }
+ rrset_array_unlock(r->ref, r->rrset_count);
+ }
+ }
+ lock_rw_unlock(&e->lock);
+ } else {
+ log_info("invalidateQueryInCache: qinfo is not in cache");
}
- lock_rw_unlock(&e->lock);
- } else {
- log_info("invalidateQueryInCache: qinfo is not in cache");
- }
}
/* Create response according to the ldns packet content */
int createResponse(struct module_qstate* qstate, sldns_buffer* pkt)
{
- struct msg_parse* prs;
- struct edns_data edns;
-
- /* parse message */
- prs = (struct msg_parse*) regional_alloc(qstate->env->scratch, sizeof(struct msg_parse));
- if (!prs) {
- log_err("storeResponse: out of memory on incoming message");
- return 0;
- }
-
- memset(prs, 0, sizeof(*prs));
- memset(&edns, 0, sizeof(edns));
-
- sldns_buffer_set_position(pkt, 0);
- if (parse_packet(pkt, prs, qstate->env->scratch) != LDNS_RCODE_NOERROR) {
- verbose(VERB_ALGO, "storeResponse: parse error on reply packet");
- return 0;
- }
- /* edns is not examined, but removed from message to help cache */
- if(parse_extract_edns(prs, &edns, qstate->env->scratch) !=
- LDNS_RCODE_NOERROR)
- return 0;
-
- /* remove CD-bit, we asked for in case we handle validation ourself */
- prs->flags &= ~BIT_CD;
-
- /* allocate response dns_msg in region */
- qstate->return_msg = (struct dns_msg*)regional_alloc(qstate->region, sizeof(struct dns_msg));
- if (!qstate->return_msg)
- return 0;
-
- memset(qstate->return_msg, 0, sizeof(*qstate->return_msg));
- if(!parse_create_msg(pkt, prs, NULL, &(qstate->return_msg)->qinfo, &(qstate->return_msg)->rep, qstate->region)) {
- log_err("storeResponse: malloc failure: allocating incoming dns_msg");
- return 0;
- }
-
- /* Make sure that the RA flag is set (since the presence of
- * this module means that recursion is available) */
- /* qstate->return_msg->rep->flags |= BIT_RA; */
-
- /* Clear the AA flag */
- /* FIXME: does this action go here or in some other module? */
- /*qstate->return_msg->rep->flags &= ~BIT_AA; */
-
- /* make sure QR flag is on */
- /*qstate->return_msg->rep->flags |= BIT_QR; */
-
- if(verbosity >= VERB_ALGO)
- log_dns_msg("storeResponse: packet:", &qstate->return_msg->qinfo, qstate->return_msg->rep);
-
- return 1;
+ struct msg_parse* prs;
+ struct edns_data edns;
+
+ /* parse message */
+ prs = (struct msg_parse*) regional_alloc(qstate->env->scratch,
+ sizeof(struct msg_parse));
+ if(!prs) {
+ log_err("createResponse: out of memory on incoming message");
+ return 0;
+ }
+
+ memset(prs, 0, sizeof(*prs));
+ memset(&edns, 0, sizeof(edns));
+
+ sldns_buffer_set_position(pkt, 0);
+ if(parse_packet(pkt, prs, qstate->env->scratch) != LDNS_RCODE_NOERROR) {
+ verbose(VERB_ALGO, "createResponse: parse error on reply packet");
+ return 0;
+ }
+ /* edns is not examined, but removed from message to help cache */
+ if(parse_extract_edns(prs, &edns, qstate->env->scratch) !=
+ LDNS_RCODE_NOERROR)
+ return 0;
+
+ /* remove CD-bit, we asked for in case we handle validation ourself */
+ prs->flags &= ~BIT_CD;
+
+ /* allocate response dns_msg in region */
+ qstate->return_msg = (struct dns_msg*) regional_alloc(qstate->region,
+ sizeof(struct dns_msg));
+ if(!qstate->return_msg)
+ return 0;
+
+ memset(qstate->return_msg, 0, sizeof(*qstate->return_msg));
+ if(!parse_create_msg(pkt, prs, NULL, &(qstate->return_msg)->qinfo,
+ &(qstate->return_msg)->rep, qstate->region)) {
+ log_err("createResponse: malloc failure: allocating incoming dns_msg");
+ return 0;
+ }
+
+ /* Make sure that the RA flag is set (since the presence of
+ * this module means that recursion is available) */
+ /* qstate->return_msg->rep->flags |= BIT_RA; */
+
+ /* Clear the AA flag */
+ /* FIXME: does this action go here or in some other module? */
+ /*qstate->return_msg->rep->flags &= ~BIT_AA; */
+
+ /* make sure QR flag is on */
+ /*qstate->return_msg->rep->flags |= BIT_QR; */
+
+ if(verbosity >= VERB_ALGO)
+ log_dns_msg("createResponse: packet:", &qstate->return_msg->qinfo,
+ qstate->return_msg->rep);
+
+ return 1;
}
@@ -176,7 +181,7 @@ void reply_addr2str(struct comm_reply* reply, char* dest, int maxlen)
sinaddr = &((struct sockaddr_in6*)&(reply->addr))->sin6_addr;
dest[0] = 0;
if (inet_ntop(af, sinaddr, dest, (socklen_t)maxlen) == 0)
- return;
+ return;
dest[maxlen-1] = 0;
}
@@ -190,6 +195,6 @@ void delegpt_addr_addr2str(struct delegpt_addr* target, char *dest, int maxlen)
sinaddr = &((struct sockaddr_in6*)&(target->addr))->sin6_addr;
dest[0] = 0;
if (inet_ntop(af, sinaddr, dest, (socklen_t)maxlen) == 0)
- return;
+ return;
dest[maxlen-1] = 0;
}
diff --git a/pythonmod/pythonmod_utils.h b/pythonmod/pythonmod_utils.h
index 4ea86f9bee4c..3fb0c0d7fd51 100644
--- a/pythonmod/pythonmod_utils.h
+++ b/pythonmod/pythonmod_utils.h
@@ -1,22 +1,22 @@
/*
* pythonmod_utils.h: utils header file
- *
+ *
* Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
* Marek Vavrusa (xvavru00 AT stud.fit.vutbr.cz)
*
* This software is open source.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the organization nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
@@ -46,34 +46,38 @@ struct delegpt_addr;
struct sldns_buffer;
/**
- * Store the reply_info and query_info pair in message cache (qstate->msg_cache)
+ * Store the reply_info and query_info pair in message cache
+ * (qstate->msg_cache).
*
* @param qstate: module environment
* @param qinfo: query info, the query for which answer is stored.
* @param msgrep: reply in dns_msg
* @param is_referral: If true, then the given message to be stored is a
- * referral. The cache implementation may use this as a hint.
- * It will store only the RRsets, not the message.
+ * referral. The cache implementation may use this as a hint.
+ * It will store only the RRsets, not the message.
* @return 0 on alloc error (out of memory).
*/
-int storeQueryInCache(struct module_qstate* qstate, struct query_info* qinfo, struct reply_info* msgrep, int is_referral);
+int storeQueryInCache(struct module_qstate* qstate, struct query_info* qinfo,
+ struct reply_info* msgrep, int is_referral);
/**
- * Invalidate the message associated with query_info stored in message cache.
+ * Invalidate the message associated with query_info stored in message cache.
*
- * This function invalidates the record in message cache associated with the given query only if such a record exists.
+ * This function invalidates the record in message cache associated with the
+ * given query only if such a record exists.
*
* @param qstate: module environment
* @param qinfo: query info, the query for which answer is stored.
*/
-void invalidateQueryInCache(struct module_qstate* qstate, struct query_info* qinfo);
+void invalidateQueryInCache(struct module_qstate* qstate,
+ struct query_info* qinfo);
/**
- * Create response according to the ldns packet content
+ * Create response according to the ldns packet content.
+ *
+ * This function fills qstate.return_msg up with data of a given packet
*
- * This function fills qstate.return_msg up with data of a given packet
- *
* @param qstate: module environment
* @param pkt: a sldns_buffer which contains sldns_packet data
* @return 0 on failure, out of memory or parse error.
@@ -81,14 +85,20 @@ void invalidateQueryInCache(struct module_qstate* qstate, struct query_info* qin
int createResponse(struct module_qstate* qstate, struct sldns_buffer* pkt);
/**
- * Convert reply->addr to string
- * @param reply: comm reply with address in it.
- * @param dest: destination string.
- * @param maxlen: length of string buffer.
+ * Convert reply->addr to string.
+ * @param reply: comm reply with address in it.
+ * @param dest: destination string.
+ * @param maxlen: length of string buffer.
*/
void reply_addr2str(struct comm_reply* reply, char* dest, int maxlen);
-/* Convert target->addr to string */
-void delegpt_addr_addr2str(struct delegpt_addr* target, char *dest, int maxlen);
+/**
+ * Convert target->addr to string.
+ * @param target: delegpt_addr with address in it.
+ * @param dest: destination string.
+ * @param maxlen: length of string buffer.
+ */
+void delegpt_addr_addr2str(struct delegpt_addr* target, char *dest,
+ int maxlen);
#endif /* PYTHONMOD_UTILS_H */