1 /* $NetBSD: dlz_dbi.h,v 1.1.1.3 2014/12/10 03:34:31 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl. 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the 8 * above copyright notice and this permission notice appear in all 9 * copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND STICHTING NLNET 12 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 14 * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 17 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE 18 * USE OR PERFORMANCE OF THIS SOFTWARE. 19 * 20 * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was 21 * conceived and contributed by Rob Butler. 22 * 23 * Permission to use, copy, modify, and distribute this software for any 24 * purpose with or without fee is hereby granted, provided that the 25 * above copyright notice and this permission notice appear in all 26 * copies. 27 * 28 * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER 29 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 31 * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 32 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 33 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 34 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE 35 * USE OR PERFORMANCE OF THIS SOFTWARE. 36 */ 37 38 #include <dlz_minimal.h> 39 #include <dlz_list.h> 40 #include <dlz_pthread.h> 41 42 #ifndef DLZ_DBI_H 43 #define DLZ_DBI_H 1 44 45 /* 46 * Types 47 */ 48 #define REQUIRE_CLIENT 0x01 49 #define REQUIRE_QUERY 0x02 50 #define REQUIRE_RECORD 0x04 51 #define REQUIRE_ZONE 0x08 52 53 typedef struct query_segment query_segment_t; 54 typedef DLZ_LIST(query_segment_t) query_list_t; 55 typedef struct dbinstance dbinstance_t; 56 typedef DLZ_LIST(dbinstance_t) db_list_t; 57 typedef struct driverinstance driverinstance_t; 58 59 /*% 60 * a query segment is all the text between our special tokens 61 * special tokens are %zone%, %record%, %client% 62 */ 63 struct query_segment { 64 void *cmd; 65 unsigned int strlen; 66 isc_boolean_t direct; 67 DLZ_LINK(query_segment_t) link; 68 }; 69 70 /*% 71 * a database instance contains everything we need for running 72 * a query against the database. Using it each separate thread 73 * can dynamically construct a query and execute it against the 74 * database. The "instance_lock" and locking code in the driver's 75 * make sure no two threads try to use the same DBI at a time. 76 */ 77 struct dbinstance { 78 void *dbconn; 79 query_list_t *allnodes_q; 80 query_list_t *allowxfr_q; 81 query_list_t *authority_q; 82 query_list_t *findzone_q; 83 query_list_t *lookup_q; 84 query_list_t *countzone_q; 85 char *query_buf; 86 char *zone; 87 char *record; 88 char *client; 89 dlz_mutex_t lock; 90 DLZ_LINK(dbinstance_t) link; 91 }; 92 93 /* 94 * Method declarations 95 */ 96 97 void 98 destroy_querylist(query_list_t **querylist); 99 100 isc_result_t 101 build_querylist(const char *query_str, char **zone, char **record, 102 char **client, query_list_t **querylist, unsigned int flags, 103 log_t log); 104 105 char * 106 build_querystring(query_list_t *querylist); 107 108 isc_result_t 109 build_dbinstance(const char *allnodes_str, const char *allowxfr_str, 110 const char *authority_str, const char *findzone_str, 111 const char *lookup_str, const char *countzone_str, 112 dbinstance_t **dbi, log_t log); 113 114 void 115 destroy_dbinstance(dbinstance_t *dbi); 116 117 char * 118 get_parameter_value(const char *input, const char* key); 119 120 #endif /* DLZ_DBI_H */ 121