xref: /netbsd-src/external/bsd/unbound/dist/pythonmod/pythonmod.h (revision 91f7d55fb697b5e0475da4718fa34c3a3ebeac85)
13b6c3722Schristos /*
23b6c3722Schristos  * pythonmod.h: module header file
33b6c3722Schristos  *
43b6c3722Schristos  * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
53b6c3722Schristos  *                     Marek Vavrusa  (xvavru00 AT stud.fit.vutbr.cz)
63b6c3722Schristos  *
73b6c3722Schristos  * This software is open source.
83b6c3722Schristos  *
93b6c3722Schristos  * Redistribution and use in source and binary forms, with or without
103b6c3722Schristos  * modification, are permitted provided that the following conditions
113b6c3722Schristos  * are met:
123b6c3722Schristos  *
133b6c3722Schristos  *    * Redistributions of source code must retain the above copyright notice,
143b6c3722Schristos  *      this list of conditions and the following disclaimer.
153b6c3722Schristos  *
163b6c3722Schristos  *    * Redistributions in binary form must reproduce the above copyright notice,
173b6c3722Schristos  *      this list of conditions and the following disclaimer in the documentation
183b6c3722Schristos  *      and/or other materials provided with the distribution.
193b6c3722Schristos  *
203b6c3722Schristos  *    * Neither the name of the organization nor the names of its
213b6c3722Schristos  *      contributors may be used to endorse or promote products derived from this
223b6c3722Schristos  *      software without specific prior written permission.
233b6c3722Schristos  *
243b6c3722Schristos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
253b6c3722Schristos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
263b6c3722Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
273b6c3722Schristos  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
283b6c3722Schristos  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
293b6c3722Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
303b6c3722Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
313b6c3722Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
323b6c3722Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
333b6c3722Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
343b6c3722Schristos  * POSSIBILITY OF SUCH DAMAGE.
353b6c3722Schristos  */
363b6c3722Schristos /**
373b6c3722Schristos  * \file
383b6c3722Schristos  * Python module for unbound.  Calls python script.
393b6c3722Schristos  */
403b6c3722Schristos #ifndef PYTHONMOD_H
413b6c3722Schristos #define PYTHONMOD_H
423b6c3722Schristos #include "util/module.h"
433b6c3722Schristos #include "services/outbound_list.h"
443b6c3722Schristos 
453b6c3722Schristos /**
463b6c3722Schristos  * Get the module function block.
473b6c3722Schristos  * @return: function block with function pointers to module methods.
483b6c3722Schristos  */
493b6c3722Schristos struct module_func_block* pythonmod_get_funcblock(void);
503b6c3722Schristos 
513b6c3722Schristos /** python module init */
523b6c3722Schristos int pythonmod_init(struct module_env* env, int id);
533b6c3722Schristos 
543b6c3722Schristos /** python module deinit */
553b6c3722Schristos void pythonmod_deinit(struct module_env* env, int id);
563b6c3722Schristos 
573b6c3722Schristos /** python module operate on a query */
580cd9f4ecSchristos void pythonmod_operate(struct module_qstate* qstate, enum module_ev event,
590cd9f4ecSchristos 	int id, struct outbound_entry* outbound);
603b6c3722Schristos 
613b6c3722Schristos /** python module  */
620cd9f4ecSchristos void pythonmod_inform_super(struct module_qstate* qstate, int id,
630cd9f4ecSchristos 	struct module_qstate* super);
643b6c3722Schristos 
653b6c3722Schristos /** python module cleanup query state */
663b6c3722Schristos void pythonmod_clear(struct module_qstate* qstate, int id);
673b6c3722Schristos 
683b6c3722Schristos /** python module alloc size routine */
693b6c3722Schristos size_t pythonmod_get_mem(struct module_env* env, int id);
700cd9f4ecSchristos 
710cd9f4ecSchristos /** Declared here for fptr_wlist access. The definition is in interface.i. */
720cd9f4ecSchristos int python_inplace_cb_reply_generic(struct query_info* qinfo,
730cd9f4ecSchristos 	struct module_qstate* qstate, struct reply_info* rep, int rcode,
740cd9f4ecSchristos 	struct edns_data* edns, struct edns_option** opt_list_out,
75d0eba39bSchristos 	struct comm_reply* repinfo, struct regional* region,
76d0eba39bSchristos 	struct timeval* start_time, int id, void* python_callback);
77f42d8de7Schristos 
78f42d8de7Schristos /** Declared here for fptr_wlist access. The definition is in interface.i. */
79f42d8de7Schristos int python_inplace_cb_query_generic(
80f42d8de7Schristos         struct query_info* qinfo, uint16_t flags, struct module_qstate* qstate,
81f42d8de7Schristos         struct sockaddr_storage* addr, socklen_t addrlen,
82f42d8de7Schristos         uint8_t* zone, size_t zonelen, struct regional* region, int id,
83f42d8de7Schristos         void* python_callback);
84f42d8de7Schristos 
85*91f7d55fSchristos /** Declared here for fptr_wlist access. The definition is in interface.i. */
86*91f7d55fSchristos int python_inplace_cb_query_response(struct module_qstate* qstate,
87*91f7d55fSchristos     struct dns_msg* response, int id, void* python_callback);
88*91f7d55fSchristos 
89*91f7d55fSchristos /** Declared here for fptr_wlist access. The definition is in interface.i. */
90*91f7d55fSchristos int python_inplace_cb_edns_back_parsed_call(struct module_qstate* qstate,
91*91f7d55fSchristos     int id, void* python_callback);
92*91f7d55fSchristos 
933b6c3722Schristos #endif /* PYTHONMOD_H */
94