13b6c3722Schristos /*
23b6c3722Schristos * util/fptr_wlist.c - function pointer whitelists.
33b6c3722Schristos *
43b6c3722Schristos * Copyright (c) 2007, NLnet Labs. All rights reserved.
53b6c3722Schristos *
63b6c3722Schristos * This software is open source.
73b6c3722Schristos *
83b6c3722Schristos * Redistribution and use in source and binary forms, with or without
93b6c3722Schristos * modification, are permitted provided that the following conditions
103b6c3722Schristos * are met:
113b6c3722Schristos *
123b6c3722Schristos * Redistributions of source code must retain the above copyright notice,
133b6c3722Schristos * this list of conditions and the following disclaimer.
143b6c3722Schristos *
153b6c3722Schristos * Redistributions in binary form must reproduce the above copyright notice,
163b6c3722Schristos * this list of conditions and the following disclaimer in the documentation
173b6c3722Schristos * and/or other materials provided with the distribution.
183b6c3722Schristos *
193b6c3722Schristos * Neither the name of the NLNET LABS nor the names of its contributors may
203b6c3722Schristos * be used to endorse or promote products derived from this software without
213b6c3722Schristos * specific prior written permission.
223b6c3722Schristos *
233b6c3722Schristos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
243b6c3722Schristos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
253b6c3722Schristos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
263b6c3722Schristos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
273b6c3722Schristos * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
283b6c3722Schristos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
293b6c3722Schristos * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
303b6c3722Schristos * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
313b6c3722Schristos * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
323b6c3722Schristos * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
333b6c3722Schristos * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
343b6c3722Schristos */
353b6c3722Schristos
363b6c3722Schristos /**
373b6c3722Schristos * \file
383b6c3722Schristos *
393b6c3722Schristos * This file contains functions that check function pointers.
403b6c3722Schristos * The functions contain a whitelist of known good callback values.
413b6c3722Schristos * Any other values lead to an error.
423b6c3722Schristos *
433b6c3722Schristos * Due to the listing nature, this file violates all the modularization
443b6c3722Schristos * boundaries in the program.
453b6c3722Schristos */
463b6c3722Schristos #include "config.h"
473b6c3722Schristos #include "util/fptr_wlist.h"
483b6c3722Schristos #include "util/mini_event.h"
493b6c3722Schristos #include "services/outside_network.h"
503b6c3722Schristos #include "services/mesh.h"
513b6c3722Schristos #include "services/localzone.h"
520cd9f4ecSchristos #include "services/authzone.h"
533b6c3722Schristos #include "services/cache/infra.h"
543b6c3722Schristos #include "services/cache/rrset.h"
550cd9f4ecSchristos #include "services/view.h"
563b6c3722Schristos #include "dns64/dns64.h"
573b6c3722Schristos #include "iterator/iterator.h"
583b6c3722Schristos #include "iterator/iter_fwd.h"
593b6c3722Schristos #include "validator/validator.h"
603b6c3722Schristos #include "validator/val_anchor.h"
613b6c3722Schristos #include "validator/val_nsec3.h"
623b6c3722Schristos #include "validator/val_sigcrypt.h"
633b6c3722Schristos #include "validator/val_kentry.h"
643b6c3722Schristos #include "validator/val_neg.h"
653b6c3722Schristos #include "validator/autotrust.h"
663b6c3722Schristos #include "util/data/msgreply.h"
673b6c3722Schristos #include "util/data/packed_rrset.h"
683b6c3722Schristos #include "util/storage/slabhash.h"
693b6c3722Schristos #include "util/storage/dnstree.h"
703b6c3722Schristos #include "util/locks.h"
713b6c3722Schristos #include "libunbound/libworker.h"
723b6c3722Schristos #include "libunbound/context.h"
733b6c3722Schristos #include "libunbound/worker.h"
743b6c3722Schristos #include "util/tube.h"
753b6c3722Schristos #include "util/config_file.h"
763b6c3722Schristos #ifdef UB_ON_WINDOWS
773b6c3722Schristos #include "winrc/win_svc.h"
783b6c3722Schristos #endif
790cd9f4ecSchristos #include "respip/respip.h"
803b6c3722Schristos
813b6c3722Schristos #ifdef WITH_PYTHONMODULE
823b6c3722Schristos #include "pythonmod/pythonmod.h"
833b6c3722Schristos #endif
84d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
85d0eba39bSchristos #include "dynlibmod/dynlibmod.h"
86d0eba39bSchristos #endif
873b6c3722Schristos #ifdef USE_CACHEDB
883b6c3722Schristos #include "cachedb/cachedb.h"
893b6c3722Schristos #endif
900cd9f4ecSchristos #ifdef USE_IPSECMOD
910cd9f4ecSchristos #include "ipsecmod/ipsecmod.h"
920cd9f4ecSchristos #endif
930cd9f4ecSchristos #ifdef CLIENT_SUBNET
940cd9f4ecSchristos #include "edns-subnet/subnetmod.h"
950cd9f4ecSchristos #endif
9601049ae6Schristos #ifdef USE_IPSET
9701049ae6Schristos #include "ipset/ipset.h"
9801049ae6Schristos #endif
99d0eba39bSchristos #ifdef USE_DNSTAP
100d0eba39bSchristos #include "dnstap/dtstream.h"
101d0eba39bSchristos #endif
1023b6c3722Schristos
1033b6c3722Schristos int
fptr_whitelist_comm_point(comm_point_callback_type * fptr)1040cd9f4ecSchristos fptr_whitelist_comm_point(comm_point_callback_type *fptr)
1053b6c3722Schristos {
1063b6c3722Schristos if(fptr == &worker_handle_request) return 1;
1073b6c3722Schristos else if(fptr == &outnet_udp_cb) return 1;
1083b6c3722Schristos else if(fptr == &outnet_tcp_cb) return 1;
1093b6c3722Schristos else if(fptr == &tube_handle_listen) return 1;
1107cd94d69Schristos else if(fptr == &auth_xfer_probe_udp_callback) return 1;
1117cd94d69Schristos else if(fptr == &auth_xfer_transfer_tcp_callback) return 1;
1127cd94d69Schristos else if(fptr == &auth_xfer_transfer_http_callback) return 1;
1133b6c3722Schristos return 0;
1143b6c3722Schristos }
1153b6c3722Schristos
1163b6c3722Schristos int
fptr_whitelist_comm_point_raw(comm_point_callback_type * fptr)1170cd9f4ecSchristos fptr_whitelist_comm_point_raw(comm_point_callback_type *fptr)
1183b6c3722Schristos {
1193b6c3722Schristos if(fptr == &tube_handle_listen) return 1;
1203b6c3722Schristos else if(fptr == &tube_handle_write) return 1;
1213b6c3722Schristos else if(fptr == &remote_accept_callback) return 1;
1223b6c3722Schristos else if(fptr == &remote_control_callback) return 1;
1233b6c3722Schristos return 0;
1243b6c3722Schristos }
1253b6c3722Schristos
1263b6c3722Schristos int
fptr_whitelist_comm_timer(void (* fptr)(void *))1273b6c3722Schristos fptr_whitelist_comm_timer(void (*fptr)(void*))
1283b6c3722Schristos {
1293b6c3722Schristos if(fptr == &pending_udp_timer_cb) return 1;
1303b6c3722Schristos else if(fptr == &outnet_tcptimer) return 1;
1313b6c3722Schristos else if(fptr == &pending_udp_timer_delay_cb) return 1;
1323b6c3722Schristos else if(fptr == &worker_stat_timer_cb) return 1;
1333b6c3722Schristos else if(fptr == &worker_probe_timer_cb) return 1;
134*91f7d55fSchristos else if(fptr == &validate_suspend_timer_cb) return 1;
1353b6c3722Schristos #ifdef UB_ON_WINDOWS
1363b6c3722Schristos else if(fptr == &wsvc_cron_cb) return 1;
1373b6c3722Schristos #endif
1387cd94d69Schristos else if(fptr == &auth_xfer_timer) return 1;
1397cd94d69Schristos else if(fptr == &auth_xfer_probe_timer_callback) return 1;
14001049ae6Schristos else if(fptr == &auth_xfer_transfer_timer_callback) return 1;
141d0eba39bSchristos else if(fptr == &mesh_serve_expired_callback) return 1;
1427a540f2bSchristos else if(fptr == &serviced_timer_cb) return 1;
143d0eba39bSchristos #ifdef USE_DNSTAP
144d0eba39bSchristos else if(fptr == &mq_wakeup_cb) return 1;
145d0eba39bSchristos #endif
1463b6c3722Schristos return 0;
1473b6c3722Schristos }
1483b6c3722Schristos
1493b6c3722Schristos int
fptr_whitelist_comm_signal(void (* fptr)(int,void *))1503b6c3722Schristos fptr_whitelist_comm_signal(void (*fptr)(int, void*))
1513b6c3722Schristos {
1523b6c3722Schristos if(fptr == &worker_sighandler) return 1;
1533b6c3722Schristos return 0;
1543b6c3722Schristos }
1553b6c3722Schristos
fptr_whitelist_start_accept(void (* fptr)(void *))1563b6c3722Schristos int fptr_whitelist_start_accept(void (*fptr)(void*))
1573b6c3722Schristos {
1583b6c3722Schristos if(fptr == &worker_start_accept) return 1;
1593b6c3722Schristos return 0;
1603b6c3722Schristos }
1613b6c3722Schristos
fptr_whitelist_stop_accept(void (* fptr)(void *))1623b6c3722Schristos int fptr_whitelist_stop_accept(void (*fptr)(void*))
1633b6c3722Schristos {
1643b6c3722Schristos if(fptr == &worker_stop_accept) return 1;
1653b6c3722Schristos return 0;
1663b6c3722Schristos }
1673b6c3722Schristos
1683b6c3722Schristos int
fptr_whitelist_event(void (* fptr)(int,short,void *))1693b6c3722Schristos fptr_whitelist_event(void (*fptr)(int, short, void *))
1703b6c3722Schristos {
1713b6c3722Schristos if(fptr == &comm_point_udp_callback) return 1;
172*91f7d55fSchristos #if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_RECVMSG)
1733b6c3722Schristos else if(fptr == &comm_point_udp_ancil_callback) return 1;
174*91f7d55fSchristos #endif
1753b6c3722Schristos else if(fptr == &comm_point_tcp_accept_callback) return 1;
1763b6c3722Schristos else if(fptr == &comm_point_tcp_handle_callback) return 1;
1773b6c3722Schristos else if(fptr == &comm_timer_callback) return 1;
1783b6c3722Schristos else if(fptr == &comm_signal_callback) return 1;
1793b6c3722Schristos else if(fptr == &comm_point_local_handle_callback) return 1;
1803b6c3722Schristos else if(fptr == &comm_point_raw_handle_callback) return 1;
1813b6c3722Schristos else if(fptr == &tube_handle_signal) return 1;
1823b6c3722Schristos else if(fptr == &comm_base_handle_slow_accept) return 1;
1837cd94d69Schristos else if(fptr == &comm_point_http_handle_callback) return 1;
184d0eba39bSchristos #ifdef USE_DNSTAP
185d0eba39bSchristos else if(fptr == &dtio_output_cb) return 1;
186d0eba39bSchristos else if(fptr == &dtio_cmd_cb) return 1;
187d0eba39bSchristos else if(fptr == &dtio_reconnect_timeout_cb) return 1;
188d0eba39bSchristos else if(fptr == &dtio_stop_timer_cb) return 1;
189d0eba39bSchristos else if(fptr == &dtio_stop_ev_cb) return 1;
190d0eba39bSchristos else if(fptr == &dtio_tap_callback) return 1;
191d0eba39bSchristos else if(fptr == &dtio_mainfdcallback) return 1;
192d0eba39bSchristos #endif
1933b6c3722Schristos #ifdef UB_ON_WINDOWS
1943b6c3722Schristos else if(fptr == &worker_win_stop_cb) return 1;
1953b6c3722Schristos #endif
1963b6c3722Schristos return 0;
1973b6c3722Schristos }
1983b6c3722Schristos
1993b6c3722Schristos int
fptr_whitelist_pending_udp(comm_point_callback_type * fptr)2000cd9f4ecSchristos fptr_whitelist_pending_udp(comm_point_callback_type *fptr)
2013b6c3722Schristos {
2023b6c3722Schristos if(fptr == &serviced_udp_callback) return 1;
2033b6c3722Schristos return 0;
2043b6c3722Schristos }
2053b6c3722Schristos
2063b6c3722Schristos int
fptr_whitelist_pending_tcp(comm_point_callback_type * fptr)2070cd9f4ecSchristos fptr_whitelist_pending_tcp(comm_point_callback_type *fptr)
2083b6c3722Schristos {
2093b6c3722Schristos if(fptr == &serviced_tcp_callback) return 1;
2103b6c3722Schristos return 0;
2113b6c3722Schristos }
2123b6c3722Schristos
2133b6c3722Schristos int
fptr_whitelist_serviced_query(comm_point_callback_type * fptr)2140cd9f4ecSchristos fptr_whitelist_serviced_query(comm_point_callback_type *fptr)
2153b6c3722Schristos {
2163b6c3722Schristos if(fptr == &worker_handle_service_reply) return 1;
2173b6c3722Schristos else if(fptr == &libworker_handle_service_reply) return 1;
2183b6c3722Schristos return 0;
2193b6c3722Schristos }
2203b6c3722Schristos
2213b6c3722Schristos int
fptr_whitelist_rbtree_cmp(int (* fptr)(const void *,const void *))2223b6c3722Schristos fptr_whitelist_rbtree_cmp(int (*fptr) (const void *, const void *))
2233b6c3722Schristos {
2243b6c3722Schristos if(fptr == &mesh_state_compare) return 1;
2253b6c3722Schristos else if(fptr == &mesh_state_ref_compare) return 1;
2263b6c3722Schristos else if(fptr == &addr_tree_compare) return 1;
227*91f7d55fSchristos else if(fptr == &addr_tree_addrport_compare) return 1;
2283b6c3722Schristos else if(fptr == &local_zone_cmp) return 1;
2293b6c3722Schristos else if(fptr == &local_data_cmp) return 1;
2303b6c3722Schristos else if(fptr == &fwd_cmp) return 1;
2313b6c3722Schristos else if(fptr == &pending_cmp) return 1;
2323b6c3722Schristos else if(fptr == &serviced_cmp) return 1;
233d0eba39bSchristos else if(fptr == &reuse_cmp) return 1;
234d0eba39bSchristos else if(fptr == &reuse_id_cmp) return 1;
2353b6c3722Schristos else if(fptr == &name_tree_compare) return 1;
2363b6c3722Schristos else if(fptr == &order_lock_cmp) return 1;
2373b6c3722Schristos else if(fptr == &codeline_cmp) return 1;
2383b6c3722Schristos else if(fptr == &nsec3_hash_cmp) return 1;
2393b6c3722Schristos else if(fptr == &mini_ev_cmp) return 1;
2403b6c3722Schristos else if(fptr == &anchor_cmp) return 1;
2413b6c3722Schristos else if(fptr == &canonical_tree_compare) return 1;
2423b6c3722Schristos else if(fptr == &context_query_cmp) return 1;
2433b6c3722Schristos else if(fptr == &val_neg_data_compare) return 1;
2443b6c3722Schristos else if(fptr == &val_neg_zone_compare) return 1;
2453b6c3722Schristos else if(fptr == &probetree_cmp) return 1;
2463b6c3722Schristos else if(fptr == &replay_var_compare) return 1;
2470cd9f4ecSchristos else if(fptr == &view_cmp) return 1;
2480cd9f4ecSchristos else if(fptr == &auth_zone_cmp) return 1;
2490cd9f4ecSchristos else if(fptr == &auth_data_cmp) return 1;
2507cd94d69Schristos else if(fptr == &auth_xfer_cmp) return 1;
2513b6c3722Schristos return 0;
2523b6c3722Schristos }
2533b6c3722Schristos
2543b6c3722Schristos int
fptr_whitelist_hash_sizefunc(lruhash_sizefunc_type fptr)2550cd9f4ecSchristos fptr_whitelist_hash_sizefunc(lruhash_sizefunc_type fptr)
2563b6c3722Schristos {
2573b6c3722Schristos if(fptr == &msgreply_sizefunc) return 1;
2583b6c3722Schristos else if(fptr == &ub_rrset_sizefunc) return 1;
2593b6c3722Schristos else if(fptr == &infra_sizefunc) return 1;
2603b6c3722Schristos else if(fptr == &key_entry_sizefunc) return 1;
2613b6c3722Schristos else if(fptr == &rate_sizefunc) return 1;
2620cd9f4ecSchristos else if(fptr == &ip_rate_sizefunc) return 1;
2633b6c3722Schristos else if(fptr == &test_slabhash_sizefunc) return 1;
2640cd9f4ecSchristos #ifdef CLIENT_SUBNET
2650cd9f4ecSchristos else if(fptr == &msg_cache_sizefunc) return 1;
2660cd9f4ecSchristos #endif
2670cd9f4ecSchristos #ifdef USE_DNSCRYPT
2680cd9f4ecSchristos else if(fptr == &dnsc_shared_secrets_sizefunc) return 1;
2690cd9f4ecSchristos else if(fptr == &dnsc_nonces_sizefunc) return 1;
2700cd9f4ecSchristos #endif
2713b6c3722Schristos return 0;
2723b6c3722Schristos }
2733b6c3722Schristos
2743b6c3722Schristos int
fptr_whitelist_hash_compfunc(lruhash_compfunc_type fptr)2750cd9f4ecSchristos fptr_whitelist_hash_compfunc(lruhash_compfunc_type fptr)
2763b6c3722Schristos {
2773b6c3722Schristos if(fptr == &query_info_compare) return 1;
2783b6c3722Schristos else if(fptr == &ub_rrset_compare) return 1;
2793b6c3722Schristos else if(fptr == &infra_compfunc) return 1;
2803b6c3722Schristos else if(fptr == &key_entry_compfunc) return 1;
2813b6c3722Schristos else if(fptr == &rate_compfunc) return 1;
2820cd9f4ecSchristos else if(fptr == &ip_rate_compfunc) return 1;
2833b6c3722Schristos else if(fptr == &test_slabhash_compfunc) return 1;
2840cd9f4ecSchristos #ifdef USE_DNSCRYPT
2850cd9f4ecSchristos else if(fptr == &dnsc_shared_secrets_compfunc) return 1;
2860cd9f4ecSchristos else if(fptr == &dnsc_nonces_compfunc) return 1;
2870cd9f4ecSchristos #endif
2883b6c3722Schristos return 0;
2893b6c3722Schristos }
2903b6c3722Schristos
2913b6c3722Schristos int
fptr_whitelist_hash_delkeyfunc(lruhash_delkeyfunc_type fptr)2920cd9f4ecSchristos fptr_whitelist_hash_delkeyfunc(lruhash_delkeyfunc_type fptr)
2933b6c3722Schristos {
2943b6c3722Schristos if(fptr == &query_entry_delete) return 1;
2953b6c3722Schristos else if(fptr == &ub_rrset_key_delete) return 1;
2963b6c3722Schristos else if(fptr == &infra_delkeyfunc) return 1;
2973b6c3722Schristos else if(fptr == &key_entry_delkeyfunc) return 1;
2983b6c3722Schristos else if(fptr == &rate_delkeyfunc) return 1;
2990cd9f4ecSchristos else if(fptr == &ip_rate_delkeyfunc) return 1;
3003b6c3722Schristos else if(fptr == &test_slabhash_delkey) return 1;
3010cd9f4ecSchristos #ifdef USE_DNSCRYPT
3020cd9f4ecSchristos else if(fptr == &dnsc_shared_secrets_delkeyfunc) return 1;
3030cd9f4ecSchristos else if(fptr == &dnsc_nonces_delkeyfunc) return 1;
3040cd9f4ecSchristos #endif
3053b6c3722Schristos return 0;
3063b6c3722Schristos }
3073b6c3722Schristos
3083b6c3722Schristos int
fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_type fptr)3090cd9f4ecSchristos fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_type fptr)
3103b6c3722Schristos {
3113b6c3722Schristos if(fptr == &reply_info_delete) return 1;
3123b6c3722Schristos else if(fptr == &rrset_data_delete) return 1;
3133b6c3722Schristos else if(fptr == &infra_deldatafunc) return 1;
3143b6c3722Schristos else if(fptr == &key_entry_deldatafunc) return 1;
3153b6c3722Schristos else if(fptr == &rate_deldatafunc) return 1;
3163b6c3722Schristos else if(fptr == &test_slabhash_deldata) return 1;
3170cd9f4ecSchristos #ifdef CLIENT_SUBNET
3180cd9f4ecSchristos else if(fptr == &subnet_data_delete) return 1;
3190cd9f4ecSchristos #endif
3200cd9f4ecSchristos #ifdef USE_DNSCRYPT
3210cd9f4ecSchristos else if(fptr == &dnsc_shared_secrets_deldatafunc) return 1;
3220cd9f4ecSchristos else if(fptr == &dnsc_nonces_deldatafunc) return 1;
3230cd9f4ecSchristos #endif
3243b6c3722Schristos return 0;
3253b6c3722Schristos }
3263b6c3722Schristos
3273b6c3722Schristos int
fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_type fptr)3280cd9f4ecSchristos fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_type fptr)
3293b6c3722Schristos {
3303b6c3722Schristos if(fptr == NULL) return 1;
3313b6c3722Schristos else if(fptr == &rrset_markdel) return 1;
332f42d8de7Schristos #ifdef CLIENT_SUBNET
333f42d8de7Schristos else if(fptr == &subnet_markdel) return 1;
334f42d8de7Schristos #endif
3353b6c3722Schristos return 0;
3363b6c3722Schristos }
3373b6c3722Schristos
3383b6c3722Schristos /** whitelist env->send_query callbacks */
3393b6c3722Schristos int
fptr_whitelist_modenv_send_query(struct outbound_entry * (* fptr)(struct query_info * qinfo,uint16_t flags,int dnssec,int want_dnssec,int nocaps,int check_ratelimit,struct sockaddr_storage * addr,socklen_t addrlen,uint8_t * zone,size_t zonelen,int tcp_upstream,int ssl_upstream,char * tls_auth_name,struct module_qstate * q,int * was_ratelimited))3403b6c3722Schristos fptr_whitelist_modenv_send_query(struct outbound_entry* (*fptr)(
3410cd9f4ecSchristos struct query_info* qinfo, uint16_t flags, int dnssec, int want_dnssec,
3427a540f2bSchristos int nocaps, int check_ratelimit, struct sockaddr_storage* addr,
3437a540f2bSchristos socklen_t addrlen, uint8_t* zone, size_t zonelen, int tcp_upstream,
3447a540f2bSchristos int ssl_upstream, char* tls_auth_name, struct module_qstate* q,
3457a540f2bSchristos int* was_ratelimited))
3463b6c3722Schristos {
3473b6c3722Schristos if(fptr == &worker_send_query) return 1;
3483b6c3722Schristos else if(fptr == &libworker_send_query) return 1;
3493b6c3722Schristos return 0;
3503b6c3722Schristos }
3513b6c3722Schristos
3523b6c3722Schristos int
fptr_whitelist_modenv_detach_subs(void (* fptr)(struct module_qstate * qstate))3533b6c3722Schristos fptr_whitelist_modenv_detach_subs(void (*fptr)(
3543b6c3722Schristos struct module_qstate* qstate))
3553b6c3722Schristos {
3563b6c3722Schristos if(fptr == &mesh_detach_subs) return 1;
3573b6c3722Schristos return 0;
3583b6c3722Schristos }
3593b6c3722Schristos
3603b6c3722Schristos int
fptr_whitelist_modenv_attach_sub(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,uint16_t qflags,int prime,int valrec,struct module_qstate ** newq))3613b6c3722Schristos fptr_whitelist_modenv_attach_sub(int (*fptr)(
3623b6c3722Schristos struct module_qstate* qstate, struct query_info* qinfo,
3633b6c3722Schristos uint16_t qflags, int prime, int valrec, struct module_qstate** newq))
3643b6c3722Schristos {
3653b6c3722Schristos if(fptr == &mesh_attach_sub) return 1;
3663b6c3722Schristos return 0;
3673b6c3722Schristos }
3683b6c3722Schristos
3693b6c3722Schristos int
fptr_whitelist_modenv_add_sub(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,uint16_t qflags,int prime,int valrec,struct module_qstate ** newq,struct mesh_state ** sub))3700cd9f4ecSchristos fptr_whitelist_modenv_add_sub(int (*fptr)(
3710cd9f4ecSchristos struct module_qstate* qstate, struct query_info* qinfo,
3720cd9f4ecSchristos uint16_t qflags, int prime, int valrec, struct module_qstate** newq,
3730cd9f4ecSchristos struct mesh_state** sub))
3740cd9f4ecSchristos {
3750cd9f4ecSchristos if(fptr == &mesh_add_sub) return 1;
3760cd9f4ecSchristos return 0;
3770cd9f4ecSchristos }
3780cd9f4ecSchristos
3790cd9f4ecSchristos int
fptr_whitelist_modenv_kill_sub(void (* fptr)(struct module_qstate * newq))3803b6c3722Schristos fptr_whitelist_modenv_kill_sub(void (*fptr)(struct module_qstate* newq))
3813b6c3722Schristos {
3823b6c3722Schristos if(fptr == &mesh_state_delete) return 1;
3833b6c3722Schristos return 0;
3843b6c3722Schristos }
3853b6c3722Schristos
3863b6c3722Schristos int
fptr_whitelist_modenv_detect_cycle(int (* fptr)(struct module_qstate * qstate,struct query_info * qinfo,uint16_t flags,int prime,int valrec))3873b6c3722Schristos fptr_whitelist_modenv_detect_cycle(int (*fptr)(
3883b6c3722Schristos struct module_qstate* qstate, struct query_info* qinfo,
3893b6c3722Schristos uint16_t flags, int prime, int valrec))
3903b6c3722Schristos {
3913b6c3722Schristos if(fptr == &mesh_detect_cycle) return 1;
3923b6c3722Schristos return 0;
3933b6c3722Schristos }
3943b6c3722Schristos
3953b6c3722Schristos int
fptr_whitelist_mod_init(int (* fptr)(struct module_env * env,int id))3963b6c3722Schristos fptr_whitelist_mod_init(int (*fptr)(struct module_env* env, int id))
3973b6c3722Schristos {
3983b6c3722Schristos if(fptr == &iter_init) return 1;
3993b6c3722Schristos else if(fptr == &val_init) return 1;
4003b6c3722Schristos else if(fptr == &dns64_init) return 1;
4010cd9f4ecSchristos else if(fptr == &respip_init) return 1;
4023b6c3722Schristos #ifdef WITH_PYTHONMODULE
4033b6c3722Schristos else if(fptr == &pythonmod_init) return 1;
4043b6c3722Schristos #endif
405d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
406d0eba39bSchristos else if(fptr == &dynlibmod_init) return 1;
407d0eba39bSchristos #endif
4083b6c3722Schristos #ifdef USE_CACHEDB
4093b6c3722Schristos else if(fptr == &cachedb_init) return 1;
4103b6c3722Schristos #endif
4110cd9f4ecSchristos #ifdef USE_IPSECMOD
4120cd9f4ecSchristos else if(fptr == &ipsecmod_init) return 1;
4130cd9f4ecSchristos #endif
4140cd9f4ecSchristos #ifdef CLIENT_SUBNET
4150cd9f4ecSchristos else if(fptr == &subnetmod_init) return 1;
4160cd9f4ecSchristos #endif
41701049ae6Schristos #ifdef USE_IPSET
41801049ae6Schristos else if(fptr == &ipset_init) return 1;
41901049ae6Schristos #endif
4203b6c3722Schristos return 0;
4213b6c3722Schristos }
4223b6c3722Schristos
4233b6c3722Schristos int
fptr_whitelist_mod_deinit(void (* fptr)(struct module_env * env,int id))4243b6c3722Schristos fptr_whitelist_mod_deinit(void (*fptr)(struct module_env* env, int id))
4253b6c3722Schristos {
4263b6c3722Schristos if(fptr == &iter_deinit) return 1;
4273b6c3722Schristos else if(fptr == &val_deinit) return 1;
4283b6c3722Schristos else if(fptr == &dns64_deinit) return 1;
4290cd9f4ecSchristos else if(fptr == &respip_deinit) return 1;
4303b6c3722Schristos #ifdef WITH_PYTHONMODULE
4313b6c3722Schristos else if(fptr == &pythonmod_deinit) return 1;
4323b6c3722Schristos #endif
433d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
434d0eba39bSchristos else if(fptr == &dynlibmod_deinit) return 1;
435d0eba39bSchristos #endif
4363b6c3722Schristos #ifdef USE_CACHEDB
4373b6c3722Schristos else if(fptr == &cachedb_deinit) return 1;
4383b6c3722Schristos #endif
4390cd9f4ecSchristos #ifdef USE_IPSECMOD
4400cd9f4ecSchristos else if(fptr == &ipsecmod_deinit) return 1;
4410cd9f4ecSchristos #endif
4420cd9f4ecSchristos #ifdef CLIENT_SUBNET
4430cd9f4ecSchristos else if(fptr == &subnetmod_deinit) return 1;
4440cd9f4ecSchristos #endif
44501049ae6Schristos #ifdef USE_IPSET
44601049ae6Schristos else if(fptr == &ipset_deinit) return 1;
44701049ae6Schristos #endif
4483b6c3722Schristos return 0;
4493b6c3722Schristos }
4503b6c3722Schristos
4513b6c3722Schristos int
fptr_whitelist_mod_operate(void (* fptr)(struct module_qstate * qstate,enum module_ev event,int id,struct outbound_entry * outbound))4523b6c3722Schristos fptr_whitelist_mod_operate(void (*fptr)(struct module_qstate* qstate,
4533b6c3722Schristos enum module_ev event, int id, struct outbound_entry* outbound))
4543b6c3722Schristos {
4553b6c3722Schristos if(fptr == &iter_operate) return 1;
4563b6c3722Schristos else if(fptr == &val_operate) return 1;
4573b6c3722Schristos else if(fptr == &dns64_operate) return 1;
4580cd9f4ecSchristos else if(fptr == &respip_operate) return 1;
4593b6c3722Schristos #ifdef WITH_PYTHONMODULE
4603b6c3722Schristos else if(fptr == &pythonmod_operate) return 1;
4613b6c3722Schristos #endif
462d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
463d0eba39bSchristos else if(fptr == &dynlibmod_operate) return 1;
464d0eba39bSchristos #endif
4653b6c3722Schristos #ifdef USE_CACHEDB
4663b6c3722Schristos else if(fptr == &cachedb_operate) return 1;
4673b6c3722Schristos #endif
4680cd9f4ecSchristos #ifdef USE_IPSECMOD
4690cd9f4ecSchristos else if(fptr == &ipsecmod_operate) return 1;
4700cd9f4ecSchristos #endif
4710cd9f4ecSchristos #ifdef CLIENT_SUBNET
4720cd9f4ecSchristos else if(fptr == &subnetmod_operate) return 1;
4730cd9f4ecSchristos #endif
47401049ae6Schristos #ifdef USE_IPSET
47501049ae6Schristos else if(fptr == &ipset_operate) return 1;
47601049ae6Schristos #endif
4773b6c3722Schristos return 0;
4783b6c3722Schristos }
4793b6c3722Schristos
4803b6c3722Schristos int
fptr_whitelist_mod_inform_super(void (* fptr)(struct module_qstate * qstate,int id,struct module_qstate * super))4813b6c3722Schristos fptr_whitelist_mod_inform_super(void (*fptr)(
4823b6c3722Schristos struct module_qstate* qstate, int id, struct module_qstate* super))
4833b6c3722Schristos {
4843b6c3722Schristos if(fptr == &iter_inform_super) return 1;
4853b6c3722Schristos else if(fptr == &val_inform_super) return 1;
4863b6c3722Schristos else if(fptr == &dns64_inform_super) return 1;
4870cd9f4ecSchristos else if(fptr == &respip_inform_super) return 1;
4883b6c3722Schristos #ifdef WITH_PYTHONMODULE
4893b6c3722Schristos else if(fptr == &pythonmod_inform_super) return 1;
4903b6c3722Schristos #endif
491d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
492d0eba39bSchristos else if(fptr == &dynlibmod_inform_super) return 1;
493d0eba39bSchristos #endif
4943b6c3722Schristos #ifdef USE_CACHEDB
4953b6c3722Schristos else if(fptr == &cachedb_inform_super) return 1;
4963b6c3722Schristos #endif
4970cd9f4ecSchristos #ifdef USE_IPSECMOD
4980cd9f4ecSchristos else if(fptr == &ipsecmod_inform_super) return 1;
4990cd9f4ecSchristos #endif
5000cd9f4ecSchristos #ifdef CLIENT_SUBNET
5010cd9f4ecSchristos else if(fptr == &subnetmod_inform_super) return 1;
5020cd9f4ecSchristos #endif
50301049ae6Schristos #ifdef USE_IPSET
50401049ae6Schristos else if(fptr == &ipset_inform_super) return 1;
50501049ae6Schristos #endif
5063b6c3722Schristos return 0;
5073b6c3722Schristos }
5083b6c3722Schristos
5093b6c3722Schristos int
fptr_whitelist_mod_clear(void (* fptr)(struct module_qstate * qstate,int id))5103b6c3722Schristos fptr_whitelist_mod_clear(void (*fptr)(struct module_qstate* qstate,
5113b6c3722Schristos int id))
5123b6c3722Schristos {
5133b6c3722Schristos if(fptr == &iter_clear) return 1;
5143b6c3722Schristos else if(fptr == &val_clear) return 1;
5153b6c3722Schristos else if(fptr == &dns64_clear) return 1;
5160cd9f4ecSchristos else if(fptr == &respip_clear) return 1;
5173b6c3722Schristos #ifdef WITH_PYTHONMODULE
5183b6c3722Schristos else if(fptr == &pythonmod_clear) return 1;
5193b6c3722Schristos #endif
520d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
521d0eba39bSchristos else if(fptr == &dynlibmod_clear) return 1;
522d0eba39bSchristos #endif
5233b6c3722Schristos #ifdef USE_CACHEDB
5243b6c3722Schristos else if(fptr == &cachedb_clear) return 1;
5253b6c3722Schristos #endif
5260cd9f4ecSchristos #ifdef USE_IPSECMOD
5270cd9f4ecSchristos else if(fptr == &ipsecmod_clear) return 1;
5280cd9f4ecSchristos #endif
5290cd9f4ecSchristos #ifdef CLIENT_SUBNET
5300cd9f4ecSchristos else if(fptr == &subnetmod_clear) return 1;
5310cd9f4ecSchristos #endif
53201049ae6Schristos #ifdef USE_IPSET
53301049ae6Schristos else if(fptr == &ipset_clear) return 1;
53401049ae6Schristos #endif
5353b6c3722Schristos return 0;
5363b6c3722Schristos }
5373b6c3722Schristos
5383b6c3722Schristos int
fptr_whitelist_mod_get_mem(size_t (* fptr)(struct module_env * env,int id))5393b6c3722Schristos fptr_whitelist_mod_get_mem(size_t (*fptr)(struct module_env* env, int id))
5403b6c3722Schristos {
5413b6c3722Schristos if(fptr == &iter_get_mem) return 1;
5423b6c3722Schristos else if(fptr == &val_get_mem) return 1;
5433b6c3722Schristos else if(fptr == &dns64_get_mem) return 1;
5440cd9f4ecSchristos else if(fptr == &respip_get_mem) return 1;
5453b6c3722Schristos #ifdef WITH_PYTHONMODULE
5463b6c3722Schristos else if(fptr == &pythonmod_get_mem) return 1;
5473b6c3722Schristos #endif
548d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
549d0eba39bSchristos else if(fptr == &dynlibmod_get_mem) return 1;
550d0eba39bSchristos #endif
5513b6c3722Schristos #ifdef USE_CACHEDB
5523b6c3722Schristos else if(fptr == &cachedb_get_mem) return 1;
5533b6c3722Schristos #endif
5540cd9f4ecSchristos #ifdef USE_IPSECMOD
5550cd9f4ecSchristos else if(fptr == &ipsecmod_get_mem) return 1;
5560cd9f4ecSchristos #endif
5570cd9f4ecSchristos #ifdef CLIENT_SUBNET
5580cd9f4ecSchristos else if(fptr == &subnetmod_get_mem) return 1;
5590cd9f4ecSchristos #endif
56001049ae6Schristos #ifdef USE_IPSET
56101049ae6Schristos else if(fptr == &ipset_get_mem) return 1;
56201049ae6Schristos #endif
5633b6c3722Schristos return 0;
5643b6c3722Schristos }
5653b6c3722Schristos
5663b6c3722Schristos int
fptr_whitelist_alloc_cleanup(void (* fptr)(void *))5673b6c3722Schristos fptr_whitelist_alloc_cleanup(void (*fptr)(void*))
5683b6c3722Schristos {
5693b6c3722Schristos if(fptr == &worker_alloc_cleanup) return 1;
5703b6c3722Schristos return 0;
5713b6c3722Schristos }
5723b6c3722Schristos
fptr_whitelist_tube_listen(tube_callback_type * fptr)5730cd9f4ecSchristos int fptr_whitelist_tube_listen(tube_callback_type* fptr)
5743b6c3722Schristos {
5753b6c3722Schristos if(fptr == &worker_handle_control_cmd) return 1;
5763b6c3722Schristos else if(fptr == &libworker_handle_control_cmd) return 1;
5773b6c3722Schristos return 0;
5783b6c3722Schristos }
5793b6c3722Schristos
fptr_whitelist_mesh_cb(mesh_cb_func_type fptr)5800cd9f4ecSchristos int fptr_whitelist_mesh_cb(mesh_cb_func_type fptr)
5813b6c3722Schristos {
5823b6c3722Schristos if(fptr == &libworker_fg_done_cb) return 1;
5833b6c3722Schristos else if(fptr == &libworker_bg_done_cb) return 1;
5843b6c3722Schristos else if(fptr == &libworker_event_done_cb) return 1;
5853b6c3722Schristos else if(fptr == &probe_answer_cb) return 1;
5867cd94d69Schristos else if(fptr == &auth_xfer_probe_lookup_callback) return 1;
5877cd94d69Schristos else if(fptr == &auth_xfer_transfer_lookup_callback) return 1;
5887a540f2bSchristos else if(fptr == &auth_zonemd_dnskey_lookup_callback) return 1;
5893b6c3722Schristos return 0;
5903b6c3722Schristos }
5913b6c3722Schristos
fptr_whitelist_print_func(void (* fptr)(char *,void *))5923b6c3722Schristos int fptr_whitelist_print_func(void (*fptr)(char*,void*))
5933b6c3722Schristos {
5943b6c3722Schristos if(fptr == &config_print_func) return 1;
5953b6c3722Schristos else if(fptr == &config_collate_func) return 1;
5963b6c3722Schristos else if(fptr == &remote_get_opt_ssl) return 1;
5973b6c3722Schristos return 0;
5983b6c3722Schristos }
5990cd9f4ecSchristos
fptr_whitelist_inplace_cb_reply_generic(inplace_cb_reply_func_type * fptr,enum inplace_cb_list_type type)6000cd9f4ecSchristos int fptr_whitelist_inplace_cb_reply_generic(inplace_cb_reply_func_type* fptr,
6010cd9f4ecSchristos enum inplace_cb_list_type type)
6020cd9f4ecSchristos {
6030cd9f4ecSchristos #ifndef WITH_PYTHONMODULE
6040cd9f4ecSchristos (void)fptr;
6050cd9f4ecSchristos #endif
6060cd9f4ecSchristos if(type == inplace_cb_reply) {
6070cd9f4ecSchristos #ifdef WITH_PYTHONMODULE
6080cd9f4ecSchristos if(fptr == &python_inplace_cb_reply_generic) return 1;
6090cd9f4ecSchristos #endif
610d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
611d0eba39bSchristos if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
612d0eba39bSchristos #endif
6130cd9f4ecSchristos } else if(type == inplace_cb_reply_cache) {
6140cd9f4ecSchristos #ifdef WITH_PYTHONMODULE
6150cd9f4ecSchristos if(fptr == &python_inplace_cb_reply_generic) return 1;
6160cd9f4ecSchristos #endif
617d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
618d0eba39bSchristos if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
619d0eba39bSchristos #endif
6200cd9f4ecSchristos } else if(type == inplace_cb_reply_local) {
6210cd9f4ecSchristos #ifdef WITH_PYTHONMODULE
6220cd9f4ecSchristos if(fptr == &python_inplace_cb_reply_generic) return 1;
6230cd9f4ecSchristos #endif
624d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
625d0eba39bSchristos if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
626d0eba39bSchristos #endif
6270cd9f4ecSchristos } else if(type == inplace_cb_reply_servfail) {
6280cd9f4ecSchristos #ifdef WITH_PYTHONMODULE
6290cd9f4ecSchristos if(fptr == &python_inplace_cb_reply_generic) return 1;
6300cd9f4ecSchristos #endif
631d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
632d0eba39bSchristos if(fptr == &dynlib_inplace_cb_reply_generic) return 1;
633d0eba39bSchristos #endif
6340cd9f4ecSchristos }
6350cd9f4ecSchristos return 0;
6360cd9f4ecSchristos }
6370cd9f4ecSchristos
fptr_whitelist_inplace_cb_query(inplace_cb_query_func_type * fptr)6380cd9f4ecSchristos int fptr_whitelist_inplace_cb_query(inplace_cb_query_func_type* fptr)
6390cd9f4ecSchristos {
6400cd9f4ecSchristos #ifdef CLIENT_SUBNET
6410cd9f4ecSchristos if(fptr == &ecs_whitelist_check)
6420cd9f4ecSchristos return 1;
6430cd9f4ecSchristos #endif
644f42d8de7Schristos #ifdef WITH_PYTHONMODULE
645f42d8de7Schristos if(fptr == &python_inplace_cb_query_generic)
646f42d8de7Schristos return 1;
647f42d8de7Schristos #endif
648d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
649d0eba39bSchristos if(fptr == &dynlib_inplace_cb_query_generic)
650d0eba39bSchristos return 1;
651d0eba39bSchristos #endif
652f42d8de7Schristos (void)fptr;
6530cd9f4ecSchristos return 0;
6540cd9f4ecSchristos }
6550cd9f4ecSchristos
fptr_whitelist_inplace_cb_edns_back_parsed(inplace_cb_edns_back_parsed_func_type * fptr)6560cd9f4ecSchristos int fptr_whitelist_inplace_cb_edns_back_parsed(
6570cd9f4ecSchristos inplace_cb_edns_back_parsed_func_type* fptr)
6580cd9f4ecSchristos {
6590cd9f4ecSchristos #ifdef CLIENT_SUBNET
6600cd9f4ecSchristos if(fptr == &ecs_edns_back_parsed)
6610cd9f4ecSchristos return 1;
6620cd9f4ecSchristos #else
6630cd9f4ecSchristos (void)fptr;
6640cd9f4ecSchristos #endif
665*91f7d55fSchristos #ifdef WITH_PYTHONMODULE
666*91f7d55fSchristos if(fptr == &python_inplace_cb_edns_back_parsed_call)
667*91f7d55fSchristos return 1;
668*91f7d55fSchristos #endif
669d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
670d0eba39bSchristos if(fptr == &dynlib_inplace_cb_edns_back_parsed)
671d0eba39bSchristos return 1;
672d0eba39bSchristos #endif
6730cd9f4ecSchristos return 0;
6740cd9f4ecSchristos }
6750cd9f4ecSchristos
fptr_whitelist_inplace_cb_query_response(inplace_cb_query_response_func_type * fptr)6760cd9f4ecSchristos int fptr_whitelist_inplace_cb_query_response(
6770cd9f4ecSchristos inplace_cb_query_response_func_type* fptr)
6780cd9f4ecSchristos {
6790cd9f4ecSchristos #ifdef CLIENT_SUBNET
6800cd9f4ecSchristos if(fptr == &ecs_query_response)
6810cd9f4ecSchristos return 1;
6820cd9f4ecSchristos #else
6830cd9f4ecSchristos (void)fptr;
6840cd9f4ecSchristos #endif
685*91f7d55fSchristos #ifdef WITH_PYTHONMODULE
686*91f7d55fSchristos if(fptr == &python_inplace_cb_query_response)
687*91f7d55fSchristos return 1;
688*91f7d55fSchristos #endif
689d0eba39bSchristos #ifdef WITH_DYNLIBMODULE
690d0eba39bSchristos if(fptr == &dynlib_inplace_cb_query_response)
691d0eba39bSchristos return 1;
692d0eba39bSchristos #endif
6930cd9f4ecSchristos return 0;
6940cd9f4ecSchristos }
69501049ae6Schristos
fptr_whitelist_serve_expired_lookup(serve_expired_lookup_func_type * fptr)696d0eba39bSchristos int fptr_whitelist_serve_expired_lookup(serve_expired_lookup_func_type* fptr)
697d0eba39bSchristos {
698d0eba39bSchristos if(fptr == &mesh_serve_expired_lookup)
699d0eba39bSchristos return 1;
700d0eba39bSchristos return 0;
701d0eba39bSchristos }
702