X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/adns/blobdiff_plain/ae8cc9775a6eb23901a89a2604f73525b0553db8..f930c455a13d7d30ee94bdbfc460bc6227cda111:/src/adns.h?ds=sidebyside diff --git a/src/adns.h b/src/adns.h index befa0b3..2c03416 100644 --- a/src/adns.h +++ b/src/adns.h @@ -1,6 +1,6 @@ /* * adns.h - * - adns user-visible API (single-threaded, without any locking) + * - adns user-visible API */ /* * @@ -106,9 +106,15 @@ typedef enum { /* In general, or together the desired flags: */ typedef enum { adns_rrt_typemask= 0x0ffff, - adns__qtf_deref= 0x10000,/* dereference domains; perhaps get extra data */ + adns_rrt_reprmask= 0xffffff, + adns__qtf_deref_bit=0x10000,/* internal version of ..._deref below */ adns__qtf_mail822= 0x20000,/* return mailboxes in RFC822 rcpt field fmt */ + adns__qtf_bigaddr=0x1000000,/* use the new larger sockaddr union */ + + adns__qtf_deref= adns__qtf_deref_bit|adns__qtf_bigaddr + ,/* dereference domains; perhaps get extra data */ + adns_r_unknown= 0x40000, /* To use this, ask for records of type |adns_r_unknown. * adns will not process the RDATA - you'll get adns_rr_byteblocks, @@ -282,14 +288,29 @@ typedef enum { } adns_status; +typedef union { + struct sockaddr sa; + struct sockaddr_in inet; +} adns_sockaddr_v4only; + +typedef union { + struct sockaddr sa; + struct sockaddr_in inet; + struct sockaddr_in6 inet6; +} adns_sockaddr; + typedef struct { int len; - union { - struct sockaddr sa; - struct sockaddr_in inet; - } addr; + adns_sockaddr addr; } adns_rr_addr; +typedef struct { + /* the old v4-only structure; handy if you have complicated binary + * compatibility problems. */ + int len; + adns_sockaddr_v4only addr; +} adns_rr_addr_v4only; + typedef struct { char *host; adns_status astatus; @@ -401,6 +422,18 @@ typedef struct { * requested. */ +/* Threads: + * adns does not use any static modifiable state, so it + * is safe to call adns_init several times and then use the + * resulting adns_states concurrently. + * However, it is NOT safe to make simultaneous calls into + * adns using the same adns_state; a single adns_state must be used + * only by one thread at a time. You can solve this problem by + * having one adns_state per thread, or if that isn't feasible, you + * could maintain a pool of adns_states. Unfortunately neither of + * these approaches has optimal performance. + */ + int adns_init(adns_state *newstate_r, adns_initflags flags, FILE *diagfile /*0=>stderr*/);