- Fix pythonmod for cb changes.

git-svn-id: file:///svn/unbound/trunk@4097 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2017-04-06 14:17:37 +00:00
parent 5591fdff8d
commit 06e794898f
3 changed files with 34 additions and 27 deletions

View file

@ -14,6 +14,7 @@
- Small fixup for documentation. - Small fixup for documentation.
- iana portlist update - iana portlist update
- Fix respip for braces when locks arent used. - Fix respip for braces when locks arent used.
- Fix pythonmod for cb changes.
4 April 2017: Wouter 4 April 2017: Wouter
- Fix #1244: document that use of chroot requires trust anchor file to - Fix #1244: document that use of chroot requires trust anchor file to

View file

@ -1346,7 +1346,7 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
int python_inplace_cb_reply_generic(struct query_info* qinfo, int python_inplace_cb_reply_generic(struct query_info* qinfo,
struct module_qstate* qstate, struct reply_info* rep, int rcode, struct module_qstate* qstate, struct reply_info* rep, int rcode,
struct edns_data* edns, struct edns_option** opt_list_out, struct edns_data* edns, struct edns_option** opt_list_out,
struct regional* region, void* python_callback) struct regional* region, int id, void* python_callback)
{ {
PyObject *func, *py_edns, *py_qstate, *py_opt_list_out, *py_qinfo; PyObject *func, *py_edns, *py_qstate, *py_opt_list_out, *py_qinfo;
PyObject *py_rep, *py_region; PyObject *py_rep, *py_region;
@ -1379,49 +1379,51 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
return res; return res;
} }
/* register a callback */
static int python_inplace_cb_register(enum inplace_cb_list_type type,
PyObject* py_cb, struct module_env* env)
{
int id = modstack_find(&env->mesh->mods, "python");
int ret = inplace_cb_register(python_inplace_cb_reply_generic,
type, (void*) py_cb, env, id);
if (ret) Py_INCREF(py_cb);
return ret;
}
/* Swig implementations for Python */ /* Swig implementations for Python */
static int register_inplace_cb_reply(PyObject* py_cb, static int register_inplace_cb_reply(PyObject* py_cb,
struct module_env* env) struct module_env* env)
{ {
int ret = inplace_cb_reply_register( return python_inplace_cb_register(inplace_cb_reply, py_cb, env);
python_inplace_cb_reply_generic, (void*) py_cb, env);
if (ret) Py_INCREF(py_cb);
return ret;
} }
static int register_inplace_cb_reply_cache(PyObject* py_cb, static int register_inplace_cb_reply_cache(PyObject* py_cb,
struct module_env* env) struct module_env* env)
{ {
int ret = inplace_cb_reply_cache_register( return python_inplace_cb_register(inplace_cb_reply_cache, py_cb, env);
python_inplace_cb_reply_generic, (void*) py_cb, env);
if (ret) Py_INCREF(py_cb);
return ret;
} }
static int register_inplace_cb_reply_local(PyObject* py_cb, static int register_inplace_cb_reply_local(PyObject* py_cb,
struct module_env* env) struct module_env* env)
{ {
int ret = inplace_cb_reply_local_register( return python_inplace_cb_register(inplace_cb_reply_local, py_cb, env);
python_inplace_cb_reply_generic, (void*) py_cb, env);
if (ret) Py_INCREF(py_cb);
return ret;
} }
static int register_inplace_cb_reply_servfail(PyObject* py_cb, static int register_inplace_cb_reply_servfail(PyObject* py_cb,
struct module_env* env) struct module_env* env)
{ {
int ret = inplace_cb_reply_servfail_register( return python_inplace_cb_register(inplace_cb_reply_servfail,
python_inplace_cb_reply_generic, (void*) py_cb, env); py_cb, env);
if (ret) Py_INCREF(py_cb); }
return ret; static int register_inplace_cb_query(PyObject* py_cb,
struct module_env* env)
{
return python_inplace_cb_register(inplace_cb_query, py_cb, env);
}
static int register_inplace_cb_edns_back_parsed(PyObject* py_cb,
struct module_env* env)
{
return python_inplace_cb_register(inplace_cb_edns_back_parsed,
py_cb, env);
} }
%} %}
/* C declarations */
int inplace_cb_reply_register(
inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
int inplace_cb_reply_cache_register(
inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
int inplace_cb_reply_local_register(
inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
int inplace_cb_reply_servfail_register(
inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
/* Swig declarations */ /* Swig declarations */
static int register_inplace_cb_reply(PyObject* py_cb, static int register_inplace_cb_reply(PyObject* py_cb,
@ -1432,3 +1434,7 @@ static int register_inplace_cb_reply_local(PyObject* py_cb,
struct module_env* env); struct module_env* env);
static int register_inplace_cb_reply_servfail(PyObject* py_cb, static int register_inplace_cb_reply_servfail(PyObject* py_cb,
struct module_env* env); struct module_env* env);
static int register_inplace_cb_query(PyObject* py_cb,
struct module_env* env);
static int register_inplace_cb_edns_back_parsed(PyObject* py_cb,
struct module_env* env);

View file

@ -72,5 +72,5 @@ size_t pythonmod_get_mem(struct module_env* env, int id);
int python_inplace_cb_reply_generic(struct query_info* qinfo, int python_inplace_cb_reply_generic(struct query_info* qinfo,
struct module_qstate* qstate, struct reply_info* rep, int rcode, struct module_qstate* qstate, struct reply_info* rep, int rcode,
struct edns_data* edns, struct edns_option** opt_list_out, struct edns_data* edns, struct edns_option** opt_list_out,
struct regional* region, void* python_callback); struct regional* region, int id, void* python_callback);
#endif /* PYTHONMOD_H */ #endif /* PYTHONMOD_H */