Electroneum
unbound.h
Go to the documentation of this file.
1 /*
2  * unbound.h - unbound validating resolver public API
3  *
4  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
97 #ifndef _UB_UNBOUND_H
98 #define _UB_UNBOUND_H
99 
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103 
105 #define UNBOUND_VERSION_MAJOR @UNBOUND_VERSION_MAJOR@
106 #define UNBOUND_VERSION_MINOR @UNBOUND_VERSION_MINOR@
107 #define UNBOUND_VERSION_MICRO @UNBOUND_VERSION_MICRO@
108 
116 struct ub_ctx;
117 
123 struct ub_result {
125  char* qname;
127  int qtype;
129  int qclass;
130 
137  char** data;
138 
140  int* len;
141 
147  char* canonname;
148 
153  int rcode;
154 
161 
166  int havedata;
167 
173  int nxdomain;
174 
183  int secure;
184 
196  int bogus;
197 
204  char* why_bogus;
205 
210  int ttl;
211 };
212 
226 typedef void (*ub_callback_type)(void*, int, struct ub_result*);
227 
235 struct ub_ctx* ub_ctx_create(void);
236 
242 void ub_ctx_delete(struct ub_ctx* ctx);
243 
257 int ub_ctx_set_option(struct ub_ctx* ctx, const char* opt, const char* val);
258 
273 int ub_ctx_get_option(struct ub_ctx* ctx, const char* opt, char** str);
274 
285 int ub_ctx_config(struct ub_ctx* ctx, const char* fname);
286 
304 int ub_ctx_set_fwd(struct ub_ctx* ctx, const char* addr);
305 
324 int ub_ctx_set_stub(struct ub_ctx* ctx, const char* zone, const char* addr,
325  int isprime);
326 
341 int ub_ctx_resolvconf(struct ub_ctx* ctx, const char* fname);
342 
354 int ub_ctx_hosts(struct ub_ctx* ctx, const char* fname);
355 
367 int ub_ctx_add_ta(struct ub_ctx* ctx, const char* ta);
368 
378 int ub_ctx_add_ta_file(struct ub_ctx* ctx, const char* fname);
379 
393 int ub_ctx_add_ta_autr(struct ub_ctx* ctx, const char* fname);
394 
405 int ub_ctx_trustedkeys(struct ub_ctx* ctx, const char* fname);
406 
415 int ub_ctx_debugout(struct ub_ctx* ctx, void* out);
416 
425 int ub_ctx_debuglevel(struct ub_ctx* ctx, int d);
426 
437 int ub_ctx_async(struct ub_ctx* ctx, int dothread);
438 
447 int ub_poll(struct ub_ctx* ctx);
448 
456 int ub_wait(struct ub_ctx* ctx);
457 
467 int ub_fd(struct ub_ctx* ctx);
468 
476 int ub_process(struct ub_ctx* ctx);
477 
490 int ub_resolve(struct ub_ctx* ctx, const char* name, int rrtype,
491  int rrclass, struct ub_result** result);
492 
521 int ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype,
522  int rrclass, void* mydata, ub_callback_type callback, int* async_id);
523 
537 int ub_cancel(struct ub_ctx* ctx, int async_id);
538 
543 void ub_resolve_free(struct ub_result* result);
544 
550 const char* ub_strerror(int err);
551 
557 int ub_ctx_print_local_zones(struct ub_ctx* ctx);
558 
568 int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name,
569  const char *zone_type);
570 
578 int ub_ctx_zone_remove(struct ub_ctx* ctx, const char *zone_name);
579 
588 int ub_ctx_data_add(struct ub_ctx* ctx, const char *data);
589 
596 int ub_ctx_data_remove(struct ub_ctx* ctx, const char *data);
597 
602 const char* ub_version(void);
603 
610 
611  struct {
612  long long now_sec, now_usec;
613  long long up_sec, up_usec;
615  } time;
616 
617  struct {
618  long long msg;
619  long long rrset;
620  long long val;
621  long long iter;
622  long long subnet;
623  long long ipsecmod;
624  long long respip;
626  long long dnscrypt_nonce;
627  } mem;
628 };
629 
631 #define UB_STATS_QTYPE_NUM 256
632 
633 #define UB_STATS_QCLASS_NUM 256
634 
635 #define UB_STATS_RCODE_NUM 16
636 
637 #define UB_STATS_OPCODE_NUM 16
638 
639 #define UB_STATS_BUCKET_NUM 40
640 
644  long long num_queries;
651 
659 
661  int extended;
662 
666  long long qtype_big;
670  long long qclass_big;
674  long long qtcp;
676  long long qtcp_outgoing;
678  long long qipv6;
680  long long qbit_QR;
682  long long qbit_AA;
684  long long qbit_TC;
686  long long qbit_RD;
688  long long qbit_RA;
690  long long qbit_Z;
692  long long qbit_AD;
694  long long qbit_CD;
696  long long qEDNS;
698  long long qEDNS_DO;
702  long long ans_rcode_nodata;
704  long long ans_secure;
706  long long ans_bogus;
708  long long rrset_bogus;
712  long long unwanted_replies;
714  long long unwanted_queries;
716  long long tcp_accept_usage;
724 
726  long long msg_cache_count;
728  long long rrset_cache_count;
730  long long infra_cache_count;
732  long long key_cache_count;
733 
749  long long nonce_cache_count;
760 };
761 
770 
772  long long mesh_num_states;
776  long long mesh_jostled;
778  long long mesh_dropped;
780  long long mesh_replies_sent;
785 };
786 
787 #ifdef __cplusplus
788 }
789 #endif
790 
791 #endif /* _UB_UNBOUND_H */
int qtype
Definition: unbound.h:127
long long hist[UB_STATS_BUCKET_NUM]
Definition: unbound.h:723
long long qbit_RD
Definition: unbound.h:686
int havedata
Definition: unbound.h:166
int ub_ctx_debuglevel(struct ub_ctx *ctx, int d)
int rcode
Definition: unbound.h:153
int ub_ctx_add_ta_autr(struct ub_ctx *ctx, const char *fname)
char ** data
Definition: unbound.h:137
long long subnet
Definition: unbound.h:622
long long qbit_TC
Definition: unbound.h:684
char * why_bogus
Definition: unbound.h:204
int nxdomain
Definition: unbound.h:173
long long num_query_authzone_down
Definition: unbound.h:753
struct ub_shm_stat_info::@41 time
long long now_sec
Definition: unbound.h:612
int ub_ctx_add_ta_file(struct ub_ctx *ctx, const char *fname)
int ub_ctx_data_remove(struct ub_ctx *ctx, const char *data)
int ub_ctx_zone_remove(struct ub_ctx *ctx, const char *zone_name)
long long mesh_dropped
Definition: unbound.h:778
long long iter
Definition: unbound.h:621
long long num_queries_missed_cache
Definition: unbound.h:648
long long infra_cache_count
Definition: unbound.h:730
char * qname
Definition: unbound.h:125
int ub_ctx_resolvconf(struct ub_ctx *ctx, const char *fname)
long long qtcp_outgoing
Definition: unbound.h:676
int ub_ctx_print_local_zones(struct ub_ctx *ctx)
long long qEDNS
Definition: unbound.h:696
long long num_queries_ip_ratelimited
Definition: unbound.h:646
#define UB_STATS_QCLASS_NUM
Definition: unbound.h:633
long long key_cache_count
Definition: unbound.h:732
long long num_queries_prefetch
Definition: unbound.h:650
long long ans_secure
Definition: unbound.h:704
#define UB_STATS_RCODE_NUM
Definition: unbound.h:635
#define UB_STATS_BUCKET_NUM
Definition: unbound.h:639
long long queries_ratelimited
Definition: unbound.h:710
long long sum_query_list_size
Definition: unbound.h:656
struct ub_shm_stat_info::@42 mem
long long num_query_dnscrypt_crypted
Definition: unbound.h:735
int ub_ctx_set_option(struct ub_ctx *ctx, const char *opt, const char *val)
int ttl
Definition: unbound.h:210
#define UB_STATS_OPCODE_NUM
Definition: unbound.h:637
long long rrset_cache_count
Definition: unbound.h:728
long long num_query_dnscrypt_secret_missed_cache
Definition: unbound.h:743
const char * name
char * canonname
Definition: unbound.h:147
const char * ub_strerror(int err)
long long qclass_big
Definition: unbound.h:670
int answer_len
Definition: unbound.h:160
long long qtcp
Definition: unbound.h:674
const char * ub_version(void)
long long qbit_Z
Definition: unbound.h:690
long long dnscrypt_shared_secret
Definition: unbound.h:625
long long val
Definition: unbound.h:620
long long rrset_bogus
Definition: unbound.h:708
long long num_query_dnscrypt_cleartext
Definition: unbound.h:739
long long qipv6
Definition: unbound.h:678
void(* ub_callback_type)(void *, int, struct ub_result *)
Definition: unbound.h:226
int bogus
Definition: unbound.h:196
long long unwanted_queries
Definition: unbound.h:714
long long num_query_dnscrypt_cert
Definition: unbound.h:737
int ub_resolve_async(struct ub_ctx *ctx, const char *name, int rrtype, int rrclass, void *mydata, ub_callback_type callback, int *async_id)
long long qbit_AD
Definition: unbound.h:692
long long num_query_authzone_up
Definition: unbound.h:751
long long msg
Definition: unbound.h:618
int ub_ctx_get_option(struct ub_ctx *ctx, const char *opt, char **str)
long long up_usec
Definition: unbound.h:613
long long mesh_replies_sent
Definition: unbound.h:780
long long up_sec
Definition: unbound.h:613
struct ub_ctx * ub_ctx_create(void)
double mesh_time_median
Definition: unbound.h:784
long long ans_rcode_nodata
Definition: unbound.h:702
long long elapsed_sec
Definition: unbound.h:614
long long mesh_replies_sum_wait_sec
Definition: unbound.h:782
long long mesh_num_states
Definition: unbound.h:772
int ub_ctx_data_add(struct ub_ctx *ctx, const char *data)
int ub_ctx_trustedkeys(struct ub_ctx *ctx, const char *fname)
long long qEDNS_DO
Definition: unbound.h:698
long long num_neg_cache_nxdomain
Definition: unbound.h:759
long long msg_cache_count
Definition: unbound.h:726
long long qbit_QR
Definition: unbound.h:680
long long mesh_replies_sum_wait_usec
Definition: unbound.h:782
long long mesh_num_reply_states
Definition: unbound.h:774
long long num_neg_cache_noerror
Definition: unbound.h:756
int ub_ctx_zone_add(struct ub_ctx *ctx, const char *zone_name, const char *zone_type)
long long ans_rcode[UB_STATS_RCODE_NUM]
Definition: unbound.h:700
long long ans_bogus
Definition: unbound.h:706
long long shared_secret_cache_count
Definition: unbound.h:745
int ub_ctx_set_fwd(struct ub_ctx *ctx, const char *addr)
long long unwanted_replies
Definition: unbound.h:712
long long now_usec
Definition: unbound.h:612
int ub_poll(struct ub_ctx *ctx)
int ub_ctx_hosts(struct ub_ctx *ctx, const char *fname)
long long num_query_dnscrypt_replay
Definition: unbound.h:747
void ub_ctx_delete(struct ub_ctx *ctx)
int ub_resolve(struct ub_ctx *ctx, const char *name, int rrtype, int rrclass, struct ub_result **result)
long long respip
Definition: unbound.h:624
int ub_ctx_config(struct ub_ctx *ctx, const char *fname)
int ub_cancel(struct ub_ctx *ctx, int async_id)
long long tcp_accept_usage
Definition: unbound.h:716
void ub_resolve_free(struct ub_result *result)
long long dnscrypt_nonce
Definition: unbound.h:626
long long zero_ttl_responses
Definition: unbound.h:718
long long nonce_cache_count
Definition: unbound.h:749
long long max_query_list_size
Definition: unbound.h:658
long long rrset
Definition: unbound.h:619
long long mesh_jostled
Definition: unbound.h:776
long long qbit_RA
Definition: unbound.h:688
int ub_fd(struct ub_ctx *ctx)
long long num_queries
Definition: unbound.h:644
int ub_ctx_debugout(struct ub_ctx *ctx, void *out)
int ub_ctx_async(struct ub_ctx *ctx, int dothread)
long long ipsecmod
Definition: unbound.h:623
int ub_ctx_set_stub(struct ub_ctx *ctx, const char *zone, const char *addr, int isprime)
long long num_query_dnscrypt_crypted_malformed
Definition: unbound.h:741
int * len
Definition: unbound.h:140
struct ub_server_stats svr
Definition: unbound.h:769
int dothread
Definition: context.h:91
long long qtype_big
Definition: unbound.h:666
long long elapsed_usec
Definition: unbound.h:614
long long qtype[UB_STATS_QTYPE_NUM]
Definition: unbound.h:664
long long qbit_AA
Definition: unbound.h:682
int qclass
Definition: unbound.h:129
int ub_wait(struct ub_ctx *ctx)
#define UB_STATS_QTYPE_NUM
Definition: unbound.h:631
int ub_ctx_add_ta(struct ub_ctx *ctx, const char *ta)
long long qopcode[UB_STATS_OPCODE_NUM]
Definition: unbound.h:672
long long qbit_CD
Definition: unbound.h:694
void * answer_packet
Definition: unbound.h:158
Definition: context.h:62
int secure
Definition: unbound.h:183
long long qclass[UB_STATS_QCLASS_NUM]
Definition: unbound.h:668
int ub_process(struct ub_ctx *ctx)