ReactOS 0.4.15-dev-5666-gc548b97
adns.h File Reference
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
Include dependency graph for adns.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  adns_rr_addr
 
struct  adns_rr_hostaddr
 
struct  adns_rr_strpair
 
struct  adns_rr_inthostaddr
 
struct  adns_rr_intstr
 
struct  adns_rr_intstrpair
 
struct  adns_rr_soa
 
struct  adns_answer
 

Macros

#define ADNS_API
 
#define ADNS_SOCKET   int
 
#define adns_socket_close(sck)   close(sck)
 
#define adns_socket_read(sck, data, len)   read(sck, data, len)
 
#define adns_socket_write(sck, data, len)   write(sck, data, len)
 
#define ADNS_CAPTURE_ERRNO   {}
 
#define ADNS_CLEAR_ERRNO   {}
 
#define ADNS_POLLFDS_RECOMMENDED   2
 

Typedefs

typedef struct adns__stateadns_state
 
typedef struct adns__queryadns_query
 

Enumerations

enum  adns_initflags {
  adns_if_noenv = 0x0001 , adns_if_noerrprint = 0x0002 , adns_if_noserverwarn = 0x0004 , adns_if_debug = 0x0008 ,
  adns_if_logpid = 0x0080 , adns_if_noautosys = 0x0010 , adns_if_eintr = 0x0020 , adns_if_nosigpipe = 0x0040 ,
  adns_if_checkc_entex = 0x0100 , adns_if_checkc_freq = 0x0300
}
 
enum  adns_queryflags {
  adns_qf_search = 0x00000001 , adns_qf_usevc = 0x00000002 , adns_qf_owner = 0x00000004 , adns_qf_quoteok_query = 0x00000010 ,
  adns_qf_quoteok_cname = 0x00000000 , adns_qf_quoteok_anshost = 0x00000040 , adns_qf_quotefail_cname = 0x00000080 , adns_qf_cname_loose = 0x00000100 ,
  adns_qf_cname_forbid = 0x00000200 , adns__qf_internalmask = 0x0ff00000
}
 
enum  adns_rrtype {
  adns__rrt_typemask = 0x0ffff , adns__qtf_deref = 0x10000 , adns__qtf_mail822 = 0x20000 , adns_r_none = 0 ,
  adns_r_a = 1 , adns_r_ns_raw = 2 , adns_r_ns = adns_r_ns_raw|adns__qtf_deref , adns_r_cname = 5 ,
  adns_r_soa_raw = 6 , adns_r_soa = adns_r_soa_raw|adns__qtf_mail822 , adns_r_ptr_raw = 12 , adns_r_ptr = adns_r_ptr_raw|adns__qtf_deref ,
  adns_r_hinfo = 13 , adns_r_mx_raw = 15 , adns_r_mx = adns_r_mx_raw|adns__qtf_deref , adns_r_txt = 16 ,
  adns_r_rp_raw = 17 , adns_r_rp = adns_r_rp_raw|adns__qtf_mail822 , adns_r_addr = adns_r_a|adns__qtf_deref
}
 
enum  adns_status {
  adns_s_ok , adns_s_nomemory , adns_s_unknownrrtype , adns_s_systemfail ,
  adns_s_max_localfail = 29 , adns_s_timeout , adns_s_allservfail , adns_s_norecurse ,
  adns_s_invalidresponse , adns_s_unknownformat , adns_s_max_remotefail = 59 , adns_s_rcodeservfail ,
  adns_s_rcodeformaterror , adns_s_rcodenotimplemented , adns_s_rcoderefused , adns_s_rcodeunknown ,
  adns_s_max_tempfail = 99 , adns_s_inconsistent , adns_s_prohibitedcname , adns_s_answerdomaininvalid ,
  adns_s_answerdomaintoolong , adns_s_invaliddata , adns_s_max_misconfig = 199 , adns_s_querydomainwrong ,
  adns_s_querydomaininvalid , adns_s_querydomaintoolong , adns_s_max_misquery = 299 , adns_s_nxdomain ,
  adns_s_nodata , adns_s_max_permfail = 499
}
 

Functions

ADNS_API int adns_init (adns_state *newstate_r, adns_initflags flags, FILE *diagfile)
 
ADNS_API void adns_addserver (adns_state state, struct in_addr server)
 
ADNS_API void adns_ccf_search (adns_state state, const char *fn, int lno, const char *buf)
 
ADNS_API int adns_numservers (adns_state state)
 
ADNS_API int adns_init_strcfg (adns_state *newstate_r, adns_initflags flags, FILE *diagfile, const char *configtext)
 
ADNS_API int adns_synchronous (adns_state ads, const char *owner, adns_rrtype type, adns_queryflags flags, adns_answer **answer_r)
 
ADNS_API int adns_submit (adns_state ads, const char *owner, adns_rrtype type, adns_queryflags flags, void *context, adns_query *query_r)
 
ADNS_API int adns_check (adns_state ads, adns_query *query_io, adns_answer **answer_r, void **context_r)
 
ADNS_API int adns_wait (adns_state ads, adns_query *query_io, adns_answer **answer_r, void **context_r)
 
ADNS_API int adns_wait_poll (adns_state ads, adns_query *query_io, adns_answer **answer_r, void **context_r)
 
ADNS_API void adns_cancel (adns_query query)
 
ADNS_API int adns_submit_reverse (adns_state ads, const struct sockaddr *addr, adns_rrtype type, adns_queryflags flags, void *context, adns_query *query_r)
 
ADNS_API int adns_submit_reverse_any (adns_state ads, const struct sockaddr *addr, const char *rzone, adns_rrtype type, adns_queryflags flags, void *context, adns_query *query_r)
 
ADNS_API void adns_finish (adns_state ads)
 
ADNS_API void adns_forallqueries_begin (adns_state ads)
 
ADNS_API adns_query adns_forallqueries_next (adns_state ads, void **context_r)
 
ADNS_API void adns_checkconsistency (adns_state ads, adns_query qu)
 
ADNS_API int adns_processany (adns_state ads)
 
ADNS_API int adns_processreadable (adns_state ads, ADNS_SOCKET fd, const struct timeval *now)
 
ADNS_API int adns_processwriteable (adns_state ads, ADNS_SOCKET fd, const struct timeval *now)
 
ADNS_API int adns_processexceptional (adns_state ads, ADNS_SOCKET fd, const struct timeval *now)
 
ADNS_API void adns_processtimeouts (adns_state ads, const struct timeval *now)
 
ADNS_API void adns_firsttimeout (adns_state ads, struct timeval **tv_mod, struct timeval *tv_buf, struct timeval now)
 
ADNS_API void adns_globalsystemfailure (adns_state ads)
 
ADNS_API void adns_beforeselect (adns_state ads, int *maxfd, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval **tv_mod, struct timeval *tv_buf, const struct timeval *now)
 
ADNS_API void adns_afterselect (adns_state ads, int maxfd, const fd_set *readfds, const fd_set *writefds, const fd_set *exceptfds, const struct timeval *now)
 
ADNS_API int adns_beforepoll (adns_state ads, struct pollfd *fds, int *nfds_io, int *timeout_io, const struct timeval *now)
 
ADNS_API void adns_afterpoll (adns_state ads, const struct pollfd *fds, int nfds, const struct timeval *now)
 
ADNS_API adns_status adns_rr_info (adns_rrtype type, const char **rrtname_r, const char **fmtname_r, int *len_r, const void *datap, char **data_r)
 
ADNS_API const charadns_strerror (adns_status st)
 
ADNS_API const charadns_errabbrev (adns_status st)
 
ADNS_API const charadns_errtypeabbrev (adns_status st)
 

Macro Definition Documentation

◆ ADNS_API

#define ADNS_API

Definition at line 69 of file adns.h.

◆ ADNS_CAPTURE_ERRNO

#define ADNS_CAPTURE_ERRNO   {}

Definition at line 74 of file adns.h.

◆ ADNS_CLEAR_ERRNO

#define ADNS_CLEAR_ERRNO   {}

Definition at line 75 of file adns.h.

◆ ADNS_POLLFDS_RECOMMENDED

#define ADNS_POLLFDS_RECOMMENDED   2

Definition at line 777 of file adns.h.

◆ ADNS_SOCKET

#define ADNS_SOCKET   int

Definition at line 70 of file adns.h.

◆ adns_socket_close

#define adns_socket_close (   sck)    close(sck)

Definition at line 71 of file adns.h.

◆ adns_socket_read

#define adns_socket_read (   sck,
  data,
  len 
)    read(sck, data, len)

Definition at line 72 of file adns.h.

◆ adns_socket_write

#define adns_socket_write (   sck,
  data,
  len 
)    write(sck, data, len)

Definition at line 73 of file adns.h.

Typedef Documentation

◆ adns_query

Definition at line 85 of file adns.h.

◆ adns_state

Definition at line 84 of file adns.h.

Enumeration Type Documentation

◆ adns_initflags

Enumerator
adns_if_noenv 
adns_if_noerrprint 
adns_if_noserverwarn 
adns_if_debug 
adns_if_logpid 
adns_if_noautosys 
adns_if_eintr 
adns_if_nosigpipe 
adns_if_checkc_entex 
adns_if_checkc_freq 

Definition at line 87 of file adns.h.

87 {
88 adns_if_noenv= 0x0001, /* do not look at environment */
89 adns_if_noerrprint= 0x0002, /* never print output to stderr (_debug overrides) */
90 adns_if_noserverwarn= 0x0004, /* do not warn to stderr about duff nameservers etc */
91 adns_if_debug= 0x0008, /* enable all output to stderr plus debug msgs */
92 adns_if_logpid= 0x0080, /* include pid in diagnostic output */
93 adns_if_noautosys= 0x0010, /* do not make syscalls at every opportunity */
94 adns_if_eintr= 0x0020, /* allow _wait and _synchronous to return EINTR */
95 adns_if_nosigpipe= 0x0040, /* applic has SIGPIPE set to SIG_IGN, do not protect */
96 adns_if_checkc_entex= 0x0100, /* do consistency checks on entry/exit to adns funcs */
97 adns_if_checkc_freq= 0x0300 /* do consistency checks very frequently (slow!) */
adns_initflags
Definition: adns.h:87
@ adns_if_checkc_freq
Definition: adns.h:97
@ adns_if_logpid
Definition: adns.h:92
@ adns_if_noerrprint
Definition: adns.h:89
@ adns_if_noautosys
Definition: adns.h:93
@ adns_if_noenv
Definition: adns.h:88
@ adns_if_noserverwarn
Definition: adns.h:90
@ adns_if_debug
Definition: adns.h:91
@ adns_if_eintr
Definition: adns.h:94
@ adns_if_nosigpipe
Definition: adns.h:95
@ adns_if_checkc_entex
Definition: adns.h:96

◆ adns_queryflags

Enumerator
adns_qf_search 
adns_qf_usevc 
adns_qf_owner 
adns_qf_quoteok_query 
adns_qf_quoteok_cname 
adns_qf_quoteok_anshost 
adns_qf_quotefail_cname 
adns_qf_cname_loose 
adns_qf_cname_forbid 
adns__qf_internalmask 

Definition at line 100 of file adns.h.

100 {
101 adns_qf_search= 0x00000001, /* use the searchlist */
102 adns_qf_usevc= 0x00000002, /* use a virtual circuit (TCP connection) */
103 adns_qf_owner= 0x00000004, /* fill in the owner field in the answer */
104 adns_qf_quoteok_query= 0x00000010, /* allow special chars in query domain */
105 adns_qf_quoteok_cname= 0x00000000, /* allow ... in CNAME we go via - now default */
106 adns_qf_quoteok_anshost= 0x00000040, /* allow ... in things supposed to be hostnames */
107 adns_qf_quotefail_cname= 0x00000080, /* refuse if quote-req chars in CNAME we go via */
108 adns_qf_cname_loose= 0x00000100, /* allow refs to CNAMEs - without, get _s_cname */
109 adns_qf_cname_forbid= 0x00000200, /* don't follow CNAMEs, instead give _s_cname */
110 adns__qf_internalmask= 0x0ff00000
adns_queryflags
Definition: adns.h:100
@ adns_qf_quoteok_cname
Definition: adns.h:105
@ adns_qf_usevc
Definition: adns.h:102
@ adns_qf_quoteok_query
Definition: adns.h:104
@ adns_qf_quoteok_anshost
Definition: adns.h:106
@ adns_qf_quotefail_cname
Definition: adns.h:107
@ adns_qf_search
Definition: adns.h:101
@ adns_qf_cname_forbid
Definition: adns.h:109
@ adns_qf_owner
Definition: adns.h:103
@ adns__qf_internalmask
Definition: adns.h:110
@ adns_qf_cname_loose
Definition: adns.h:108

◆ adns_rrtype

Enumerator
adns__rrt_typemask 
adns__qtf_deref 
adns__qtf_mail822 
adns_r_none 
adns_r_a 
adns_r_ns_raw 
adns_r_ns 
adns_r_cname 
adns_r_soa_raw 
adns_r_soa 
adns_r_ptr_raw 
adns_r_ptr 
adns_r_hinfo 
adns_r_mx_raw 
adns_r_mx 
adns_r_txt 
adns_r_rp_raw 
adns_r_rp 
adns_r_addr 

Definition at line 113 of file adns.h.

113 {
114 adns__rrt_typemask= 0x0ffff,
115 adns__qtf_deref= 0x10000, /* dereference domains and perhaps produce extra data */
116 adns__qtf_mail822= 0x20000, /* make mailboxes be in RFC822 rcpt field format */
117
118 adns_r_none= 0,
119
120 adns_r_a= 1,
121
122 adns_r_ns_raw= 2,
124
125 adns_r_cname= 5,
126
129
130 adns_r_ptr_raw= 12,
132
133 adns_r_hinfo= 13,
134
135 adns_r_mx_raw= 15,
137
138 adns_r_txt= 16,
139
140 adns_r_rp_raw= 17,
142
144
adns_rrtype
Definition: adns.h:113
@ adns_r_addr
Definition: adns.h:143
@ adns_r_ptr_raw
Definition: adns.h:130
@ adns_r_soa
Definition: adns.h:128
@ adns_r_mx
Definition: adns.h:136
@ adns_r_hinfo
Definition: adns.h:133
@ adns_r_rp_raw
Definition: adns.h:140
@ adns_r_cname
Definition: adns.h:125
@ adns_r_none
Definition: adns.h:118
@ adns_r_ptr
Definition: adns.h:131
@ adns__qtf_mail822
Definition: adns.h:116
@ adns_r_a
Definition: adns.h:120
@ adns_r_mx_raw
Definition: adns.h:135
@ adns__qtf_deref
Definition: adns.h:115
@ adns_r_txt
Definition: adns.h:138
@ adns_r_rp
Definition: adns.h:141
@ adns_r_soa_raw
Definition: adns.h:127
@ adns_r_ns_raw
Definition: adns.h:122
@ adns_r_ns
Definition: adns.h:123
@ adns__rrt_typemask
Definition: adns.h:114

◆ adns_status

Enumerator
adns_s_ok 
adns_s_nomemory 
adns_s_unknownrrtype 
adns_s_systemfail 
adns_s_max_localfail 
adns_s_timeout 
adns_s_allservfail 
adns_s_norecurse 
adns_s_invalidresponse 
adns_s_unknownformat 
adns_s_max_remotefail 
adns_s_rcodeservfail 
adns_s_rcodeformaterror 
adns_s_rcodenotimplemented 
adns_s_rcoderefused 
adns_s_rcodeunknown 
adns_s_max_tempfail 
adns_s_inconsistent 
adns_s_prohibitedcname 
adns_s_answerdomaininvalid 
adns_s_answerdomaintoolong 
adns_s_invaliddata 
adns_s_max_misconfig 
adns_s_querydomainwrong 
adns_s_querydomaininvalid 
adns_s_querydomaintoolong 
adns_s_max_misquery 
adns_s_nxdomain 
adns_s_nodata 
adns_s_max_permfail 

Definition at line 215 of file adns.h.

215 {
216 adns_s_ok,
217
218 /* locally induced errors */
222
224
225 /* remotely induced errors, detected locally */
231
233
234 /* remotely induced errors, reported by remote server to us */
240
242
243 /* remote configuration errors */
244 adns_s_inconsistent, /* PTR gives domain whose A does not exist and match */
245 adns_s_prohibitedcname, /* CNAME found where eg A expected (not if _qf_loosecname) */
249
251
252 /* permanent problems with the query */
256
258
259 /* permanent errors */
262
264
adns_status
Definition: adns.h:215
@ adns_s_invaliddata
Definition: adns.h:248
@ adns_s_querydomaintoolong
Definition: adns.h:255
@ adns_s_answerdomaintoolong
Definition: adns.h:247
@ adns_s_timeout
Definition: adns.h:226
@ adns_s_max_misconfig
Definition: adns.h:250
@ adns_s_unknownrrtype
Definition: adns.h:220
@ adns_s_allservfail
Definition: adns.h:227
@ adns_s_max_permfail
Definition: adns.h:263
@ adns_s_max_localfail
Definition: adns.h:223
@ adns_s_rcodeunknown
Definition: adns.h:239
@ adns_s_ok
Definition: adns.h:216
@ adns_s_unknownformat
Definition: adns.h:230
@ adns_s_prohibitedcname
Definition: adns.h:245
@ adns_s_querydomainwrong
Definition: adns.h:253
@ adns_s_nodata
Definition: adns.h:261
@ adns_s_norecurse
Definition: adns.h:228
@ adns_s_invalidresponse
Definition: adns.h:229
@ adns_s_max_misquery
Definition: adns.h:257
@ adns_s_rcodeservfail
Definition: adns.h:235
@ adns_s_max_tempfail
Definition: adns.h:241
@ adns_s_rcodeformaterror
Definition: adns.h:236
@ adns_s_systemfail
Definition: adns.h:221
@ adns_s_inconsistent
Definition: adns.h:244
@ adns_s_rcoderefused
Definition: adns.h:238
@ adns_s_max_remotefail
Definition: adns.h:232
@ adns_s_answerdomaininvalid
Definition: adns.h:246
@ adns_s_rcodenotimplemented
Definition: adns.h:237
@ adns_s_querydomaininvalid
Definition: adns.h:254
@ adns_s_nomemory
Definition: adns.h:219
@ adns_s_nxdomain
Definition: adns.h:260

Function Documentation

◆ adns_addserver()

ADNS_API void adns_addserver ( adns_state  state,
struct in_addr  server 
)

Definition at line 712 of file setup.c.

712 {
714}
adns_state ads
Definition: adh-query.c:35
GLenum const GLvoid * addr
Definition: glext.h:9621
static void addserver(adns_state ads, struct in_addr addr)
Definition: setup.c:48

Referenced by Query_Main().

◆ adns_afterpoll()

ADNS_API void adns_afterpoll ( adns_state  ads,
const struct pollfd fds,
int  nfds,
const struct timeval now 
)

◆ adns_afterselect()

ADNS_API void adns_afterselect ( adns_state  ads,
int  maxfd,
const fd_set readfds,
const fd_set writefds,
const fd_set exceptfds,
const struct timeval now 
)

Definition at line 595 of file event.c.

597 {
598 struct timeval tv_buf;
599 struct pollfd pollfds[MAX_POLLFDS];
600 int npollfds, i;
601
604 if (!now) goto xit;
606
607 npollfds= adns__pollfds(ads,pollfds);
608 for (i=0; i<npollfds; i++) pollfds[i].revents= POLLIN|POLLOUT|POLLPRI;
610 pollfds,npollfds,
611 maxfd,readfds,writefds,exceptfds,
612 *now, 0);
613xit:
615}
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
Definition: check.c:185
#define POLLIN
Definition: linux.h:1853
#define POLLOUT
Definition: linux.h:1855
#define POLLPRI
Definition: linux.h:1854
time_t now
Definition: finger.c:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io, struct timeval *tv_buf)
Definition: event.c:149
void adns__fdevents(adns_state ads, const struct pollfd *pollfds, int npollfds, int maxfd, const fd_set *readfds, const fd_set *writefds, const fd_set *exceptfds, struct timeval now, int *r_r)
Definition: event.c:542
void adns_processtimeouts(adns_state ads, const struct timeval *now)
Definition: event.c:299
int adns__pollfds(adns_state ads, struct pollfd pollfds_buf[MAX_POLLFDS])
Definition: event.c:312
#define MAX_POLLFDS
Definition: internal.h:82
@ cc_entex
Definition: internal.h:86
Definition: linux.h:1867
short revents
Definition: linux.h:1870

Referenced by adns_wait(), and main().

◆ adns_beforepoll()

ADNS_API int adns_beforepoll ( adns_state  ads,
struct pollfd fds,
int nfds_io,
int timeout_io,
const struct timeval now 
)

◆ adns_beforeselect()

ADNS_API void adns_beforeselect ( adns_state  ads,
int maxfd,
fd_set readfds,
fd_set writefds,
fd_set exceptfds,
struct timeval **  tv_mod,
struct timeval tv_buf,
const struct timeval now 
)

Definition at line 562 of file event.c.

565 {
566 struct timeval tv_nowbuf;
567 struct pollfd pollfds[MAX_POLLFDS];
568 int i, maxfd, npollfds;
570
572
573 if (tv_mod && (!*tv_mod || (*tv_mod)->tv_sec || (*tv_mod)->tv_usec)) {
574 /* The caller is planning to sleep. */
575 adns__must_gettimeofday(ads,&now,&tv_nowbuf);
576 if (!now) { inter_immed(tv_mod,tv_tobuf); goto xit; }
577 adns__timeouts(ads, 0, tv_mod,tv_tobuf, *now);
578 }
579
580 npollfds= adns__pollfds(ads,pollfds);
581 maxfd= *maxfd_io;
582 for (i=0; i<npollfds; i++) {
583 fd= pollfds[i].fd;
584 if ((int)fd >= maxfd) maxfd= fd+1;
585 if (pollfds[i].events & POLLIN) FD_SET(fd,readfds_io);
586 if (pollfds[i].events & POLLOUT) FD_SET(fd,writefds_io);
587 if (pollfds[i].events & POLLPRI) FD_SET(fd,exceptfds_io);
588 }
589 *maxfd_io= maxfd;
590
591xit:
593}
#define ADNS_SOCKET
Definition: adns_win32.h:98
HANDLE events[2]
Definition: event.c:4
void adns__timeouts(adns_state ads, int act, struct timeval **tv_io, struct timeval *tvbuf, struct timeval now)
Definition: event.c:283
static void inter_immed(struct timeval **tv_io, struct timeval *tvbuf)
Definition: event.c:162
static int fd
Definition: io.c:51
#define FD_SET(fd, set)
Definition: winsock.h:89

Referenced by adns_wait(), and main().

◆ adns_cancel()

ADNS_API void adns_cancel ( adns_query  query)

Definition at line 430 of file query.c.

430 {
432
433 ads= qu->ads;
435 if (qu->parent) LIST_UNLINK_PART(qu->parent->children,qu,siblings.);
436 switch (qu->state) {
437 case query_tosend:
438 LIST_UNLINK(ads->udpw,qu);
439 break;
440 case query_tcpw:
441 LIST_UNLINK(ads->tcpw,qu);
442 break;
443 case query_childw:
444 LIST_UNLINK(ads->childw,qu);
445 break;
446 case query_done:
448 break;
449 default:
450 abort();
451 }
453 free(qu->answer);
454 free(qu);
456}
void query_done(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:253
#define free
Definition: debug_ros.c:5
#define abort()
Definition: i386-dis.c:35
#define LIST_UNLINK_PART(list, node, part)
Definition: dlist.h:34
#define LIST_UNLINK(list, node)
Definition: dlist.h:50
static void free_query_allocs(adns_query qu)
Definition: query.c:418
struct query_queue udpw tcpw childw output
Definition: internal.h:295

Referenced by adns_finish(), adns_synchronous(), cancel_children(), and of_cancel_id().

◆ adns_ccf_search()

ADNS_API void adns_ccf_search ( adns_state  state,
const char fn,
int  lno,
const char buf 
)

Definition at line 715 of file setup.c.

715 {
716 ccf_search(ads, fn, lno, buf);
717}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:121
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

Referenced by Query_Main().

◆ adns_check()

ADNS_API int adns_check ( adns_state  ads,
adns_query query_io,
adns_answer **  answer_r,
void **  context_r 
)

Definition at line 731 of file event.c.

734 {
735 struct timeval now;
736 int r;
737
738 adns__consistency(ads,*query_io,cc_entex);
739 r= gettimeofday(&now,0);
740 if (!r) adns__autosys(ads,now);
741
742 r= adns__internal_check(ads,query_io,answer_r,context_r);
744 return r;
745}
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
void adns__autosys(adns_state ads, struct timeval now)
Definition: event.c:665
int adns__internal_check(adns_state ads, adns_query *query_io, adns_answer **answer, void **context_r)
Definition: event.c:670

Referenced by checkadnsqueries(), main(), and proclog().

◆ adns_checkconsistency()

ADNS_API void adns_checkconsistency ( adns_state  ads,
adns_query  qu 
)

Definition at line 30 of file check.c.

30 {
32}
@ cc_user
Definition: internal.h:85

◆ adns_errabbrev()

ADNS_API const char * adns_errabbrev ( adns_status  st)

Definition at line 275 of file general.c.

275 {
276 const struct sinfo *si;
277
278 si= findsinfo(st);
279 return si->abbrev;
280}
static const struct sinfo * findsinfo(adns_status st)
Definition: general.c:264
Definition: general.c:220
const char * abbrev
Definition: general.c:222
adns_status st
Definition: general.c:221

Referenced by csp_hostaddr(), main(), and print_status().

◆ adns_errtypeabbrev()

ADNS_API const char * adns_errtypeabbrev ( adns_status  st)

Definition at line 311 of file general.c.

311 {
312 const struct stinfo *sti;
313
314 sti= bsearch(&st,stinfos,sizeof(stinfos)/sizeof(*stinfos),sizeof(*stinfos),sti_compar);
315 return sti->abbrev;
316}
#define sti()
Definition: utils.h:288
static int sti_compar(const void *key, const void *elem)
Definition: general.c:298
static const struct stinfo stinfos[]
#define bsearch

Referenced by csp_hostaddr(), and print_status().

◆ adns_finish()

ADNS_API void adns_finish ( adns_state  ads)

Definition at line 650 of file setup.c.

650 {
652 for (;;) {
653 if (ads->udpw.head) adns_cancel(ads->udpw.head);
654 else if (ads->tcpw.head) adns_cancel(ads->tcpw.head);
655 else if (ads->childw.head) adns_cancel(ads->childw.head);
656 else if (ads->output.head) adns_cancel(ads->output.head);
657 else break;
658 }
664 free(ads);
665#ifdef ADNS_JGAA_WIN32
666 WSACleanup();
667#endif /* WIN32 */
668
669}
ADNS_API void adns_cancel(adns_query query)
Definition: query.c:430
#define adns_socket_close(sck)
Definition: adns_win32.h:99
void adns__vbuf_free(vbuf *vb)
Definition: general.c:155
static void freesearchlist(adns_state ads)
Definition: setup.c:69
ADNS_SOCKET tcpsocket
Definition: internal.h:298
vbuf tcprecv
Definition: internal.h:299
ADNS_SOCKET udpsocket
Definition: internal.h:298
vbuf tcpsend
Definition: internal.h:299
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60

Referenced by DnsReleaseContextHandle(), main(), proclog(), Query_Main(), and quitnow().

◆ adns_firsttimeout()

ADNS_API void adns_firsttimeout ( adns_state  ads,
struct timeval **  tv_mod,
struct timeval tv_buf,
struct timeval  now 
)

Definition at line 291 of file event.c.

293 {
295 adns__timeouts(ads, 0, tv_io,tvbuf, now);
297}

◆ adns_forallqueries_begin()

ADNS_API void adns_forallqueries_begin ( adns_state  ads)

Definition at line 671 of file setup.c.

671 {
674 ads->udpw.head ? ads->udpw.head :
675 ads->tcpw.head ? ads->tcpw.head :
676 ads->childw.head ? ads->childw.head :
677 ads->output.head;
678}
adns_query forallnext
Definition: internal.h:296

Referenced by main().

◆ adns_forallqueries_next()

ADNS_API adns_query adns_forallqueries_next ( adns_state  ads,
void **  context_r 
)

Definition at line 680 of file setup.c.

680 {
681 adns_query qu, nqu;
682
684 nqu= ads->forallnext;
685 for (;;) {
686 qu= nqu;
687 if (!qu) return 0;
688 if (qu->next) {
689 nqu= qu->next;
690 } else if (qu == ads->udpw.tail) {
691 nqu=
692 ads->tcpw.head ? ads->tcpw.head :
693 ads->childw.head ? ads->childw.head :
694 ads->output.head;
695 } else if (qu == ads->tcpw.tail) {
696 nqu=
697 ads->childw.head ? ads->childw.head :
698 ads->output.head;
699 } else if (qu == ads->childw.tail) {
700 nqu= ads->output.head;
701 } else {
702 nqu= 0;
703 }
704 if (!qu->parent) break;
705 }
706 ads->forallnext= nqu;
707 if (context_r) *context_r= qu->ctx.ext;
708 return qu;
709}
adns_query parent
Definition: internal.h:184
adns_query next
Definition: internal.h:184
qcontext ctx
Definition: internal.h:233
void * ext
Definition: internal.h:173

Referenced by main().

◆ adns_globalsystemfailure()

ADNS_API void adns_globalsystemfailure ( adns_state  ads)

Definition at line 619 of file event.c.

619 {
621
622 while (ads->udpw.head) adns__query_fail(ads->udpw.head, adns_s_systemfail);
623 while (ads->tcpw.head) adns__query_fail(ads->tcpw.head, adns_s_systemfail);
624
625 switch (ads->tcpstate) {
626 case server_connecting:
627 case server_ok:
629 break;
630 case server_disconnected:
631 case server_broken:
632 break;
633 default:
634 abort();
635 }
637}
void adns__tcp_broken(adns_state ads, const char *what, const char *why)
Definition: event.c:59
void adns__query_fail(adns_query qu, adns_status stat)
Definition: query.c:547
enum adns__state::adns__tcpstate tcpstate

Referenced by adns__must_gettimeofday(), adns_wait(), and fd_event().

◆ adns_init()

ADNS_API int adns_init ( adns_state newstate_r,
adns_initflags  flags,
FILE diagfile 
)

Definition at line 568 of file setup.c.

568 {
570 const char *res_options, *adns_res_options;
571 int r;
572#ifdef ADNS_JGAA_WIN32
573 #define SECURE_PATH_LEN (MAX_PATH - 64)
574 char PathBuf[MAX_PATH];
575#endif
576
577 r= init_begin(&ads, flags, diagfile ? diagfile : stderr);
578 if (r) return r;
579
580 res_options= instrum_getenv(ads,"RES_OPTIONS");
581 adns_res_options= instrum_getenv(ads,"ADNS_RES_OPTIONS");
582 ccf_options(ads,"RES_OPTIONS",-1,res_options);
583 ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
584
585#ifdef ADNS_JGAA_WIN32
586 GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
587 strcat(PathBuf,"\\resolv.conf");
588 readconfig(ads,PathBuf,1);
589 GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
590 strcat(PathBuf,"\\resolv-adns.conf");
591 readconfig(ads,PathBuf,0);
592 GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
593 strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf");
594 readconfig(ads,PathBuf,1);
595 GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
596 strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf");
597 readconfig(ads,PathBuf,0);
598#else
599 readconfig(ads,"/etc/resolv.conf",1);
600 readconfig(ads,"/etc/resolv-adns.conf",0);
601#endif
602
603 readconfigenv(ads,"RES_CONF");
604 readconfigenv(ads,"ADNS_RES_CONF");
605
606 readconfigenvtext(ads,"RES_CONF_TEXT");
607 readconfigenvtext(ads,"ADNS_RES_CONF_TEXT");
608
609 ccf_options(ads,"RES_OPTIONS",-1,res_options);
610 ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
611
612 ccf_search(ads,"LOCALDOMAIN",-1,instrum_getenv(ads,"LOCALDOMAIN"));
613 ccf_search(ads,"ADNS_LOCALDOMAIN",-1,instrum_getenv(ads,"ADNS_LOCALDOMAIN"));
614
615 if (ads->configerrno && ads->configerrno != EINVAL) {
616 r= ads->configerrno;
618 return r;
619 }
620
621 r= init_finish(ads);
622 if (r) return r;
623
625 *ads_r= ads;
626 return 0;
627}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define EINVAL
Definition: acclib.h:90
#define MAX_PATH
Definition: compat.h:34
GLbitfield flags
Definition: glext.h:7161
#define stderr
Definition: stdio.h:100
static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf)
Definition: setup.c:221
static int init_begin(adns_state *ads_r, adns_initflags flags, FILE *diagfile)
Definition: setup.c:471
static void readconfig(adns_state ads, const char *filename, int warnmissing)
Definition: setup.c:406
static void readconfigenvtext(adns_state ads, const char *envvar)
Definition: setup.c:445
static const char * instrum_getenv(adns_state ads, const char *envvar)
Definition: setup.c:397
static void init_abort(adns_state ads)
Definition: setup.c:556
static int init_finish(adns_state ads)
Definition: setup.c:523
static void readconfigenv(adns_state ads, const char *envvar)
Definition: setup.c:434
int configerrno
Definition: internal.h:294
#define GetWindowsDirectory
Definition: winbase.h:3728

Referenced by DnsAcquireContextHandle_W(), ensure_adns_init(), main(), proclog(), Query_Main(), and startup().

◆ adns_init_strcfg()

ADNS_API int adns_init_strcfg ( adns_state newstate_r,
adns_initflags  flags,
FILE diagfile,
const char configtext 
)

Definition at line 629 of file setup.c.

630 {
632 int r;
633
634 r= init_begin(&ads, flags, diagfile); if (r) return r;
635
636 readconfigtext(ads,configtext,"<supplied configuration text>");
637 if (ads->configerrno) {
638 r= ads->configerrno;
640 return r;
641 }
642
643 r= init_finish(ads); if (r) return r;
645 *ads_r= ads;
646 return 0;
647}
static void readconfigtext(adns_state ads, const char *text, const char *showname)
Definition: setup.c:427

Referenced by ensure_adns_init(), main(), proclog(), and startup().

◆ adns_numservers()

ADNS_API int adns_numservers ( adns_state  state)

Definition at line 718 of file setup.c.

718 {
719 return ads->nservers;
720}
int nservers
Definition: internal.h:300

Referenced by Query_Main().

◆ adns_processany()

ADNS_API int adns_processany ( adns_state  ads)

Definition at line 639 of file event.c.

639 {
640 int r, i;
641 struct timeval now;
642 struct pollfd pollfds[MAX_POLLFDS];
643 int npollfds;
644
646
647 r= gettimeofday(&now,0);
649
650 /* We just use adns__fdevents to loop over the fd's trying them.
651 * This seems more sensible than calling select, since we're most
652 * likely just to want to do a adns_socket_read on one or two fds anyway.
653 */
654 npollfds= adns__pollfds(ads,pollfds);
655 for (i=0; i<npollfds; i++) pollfds[i].revents= pollfds[i].events & ~POLLPRI;
657 pollfds,npollfds,
658 0,0,0,0,
659 now,&r);
660
662 return 0;
663}

Referenced by adns__autosys().

◆ adns_processexceptional()

ADNS_API int adns_processexceptional ( adns_state  ads,
ADNS_SOCKET  fd,
const struct timeval now 
)

Definition at line 504 of file event.c.

504 {
506 switch (ads->tcpstate) {
507 case server_disconnected:
508 case server_broken:
509 break;
510 case server_connecting:
511 case server_ok:
512 if (fd != ads->tcpsocket) break;
513 adns__tcp_broken(ads,"poll/select","exceptional condition detected");
514 break;
515 default:
516 abort();
517 }
519 return 0;
520}

Referenced by adns__fdevents().

◆ adns_processreadable()

ADNS_API int adns_processreadable ( adns_state  ads,
ADNS_SOCKET  fd,
const struct timeval now 
)

Definition at line 338 of file event.c.

338 {
339 int want, dgramlen, r, udpaddrlen, serv, old_skip;
340 byte udpbuf[DNS_MAXUDP];
341 struct sockaddr_in udpaddr;
342
344
345 switch (ads->tcpstate) {
346 case server_disconnected:
347 case server_broken:
348 case server_connecting:
349 break;
350 case server_ok:
351 if (fd != ads->tcpsocket) break;
353 do {
354 if (ads->tcprecv.used >= ads->tcprecv_skip+2) {
355 dgramlen= ((ads->tcprecv.buf[ads->tcprecv_skip]<<8) |
357 if (ads->tcprecv.used >= ads->tcprecv_skip+2+dgramlen) {
358 old_skip= ads->tcprecv_skip;
359 ads->tcprecv_skip += 2+dgramlen;
360 adns__procdgram(ads, ads->tcprecv.buf+old_skip+2,
361 dgramlen, ads->tcpserver, 1,*now);
362 continue;
363 } else {
364 want= 2+dgramlen;
365 }
366 } else {
367 want= 2;
368 }
371 ads->tcprecv_skip= 0;
372 if (!adns__vbuf_ensure(&ads->tcprecv,want)) { r= ENOMEM; goto xit; }
374 if (ads->tcprecv.used == ads->tcprecv.avail) continue;
380 if (r>0) {
381 ads->tcprecv.used+= r;
382 } else {
383 if (r) {
384 if (errno==EAGAIN || errno==EWOULDBLOCK) { r= 0; goto xit; }
385 if (errno==EINTR) continue;
386 if (errno_resources(errno)) { r= errno; goto xit; }
387 }
388 adns__tcp_broken(ads,"adns_socket_read",r?strerror(errno):"closed");
389 }
390 } while (ads->tcpstate == server_ok);
391 r= 0; goto xit;
392 default:
393 abort();
394 }
395 if (fd == ads->udpsocket) {
396 for (;;) {
397 udpaddrlen= sizeof(udpaddr);
399 r= recvfrom(ads->udpsocket,(char*)udpbuf,sizeof(udpbuf),0,
400 (struct sockaddr*)&udpaddr,&udpaddrlen);
402 if (r<0) {
403 if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ECONNRESET) { r= 0; goto xit; }
404 if (errno == EINTR) continue;
405 if (errno_resources(errno)) { r= errno; goto xit; }
406 adns__warn(ads,-1,0,"datagram receive error: %s (%d)",strerror(errno), errno);
407 r= 0; goto xit;
408 }
409 if (udpaddrlen != sizeof(udpaddr)) {
410 adns__diag(ads,-1,0,"datagram received with wrong address length %d"
411 " (expected %lu)", udpaddrlen,
412 (unsigned long)sizeof(udpaddr));
413 continue;
414 }
415 if (udpaddr.sin_family != AF_INET) {
416 adns__diag(ads,-1,0,"datagram received with wrong protocol family"
417 " %u (expected %u)",udpaddr.sin_family,AF_INET);
418 continue;
419 }
420 if (ntohs(udpaddr.sin_port) != DNS_PORT) {
421 adns__diag(ads,-1,0,"datagram received from wrong port %u (expected %u)",
422 ntohs(udpaddr.sin_port),DNS_PORT);
423 continue;
424 }
425 for (serv= 0;
426 serv < ads->nservers &&
427 ads->servers[serv].addr.s_addr != udpaddr.sin_addr.s_addr;
428 serv++);
429 if (serv >= ads->nservers) {
430 adns__warn(ads,-1,0,"datagram received from unknown nameserver %s",
431 inet_ntoa(udpaddr.sin_addr));
432 continue;
433 }
434 adns__procdgram(ads,udpbuf,r,serv,0,*now);
435 }
436 }
437 r= 0;
438xit:
440 return r;
441}
#define EINTR
Definition: acclib.h:80
#define ENOMEM
Definition: acclib.h:84
#define EAGAIN
Definition: acclib.h:83
#define adns_socket_read(sck, data, len)
Definition: adns_win32.h:100
#define ADNS_CLEAR_ERRNO
Definition: adns_win32.h:108
#define ADNS_CAPTURE_ERRNO
Definition: adns_win32.h:107
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
#define assert(x)
Definition: debug.h:53
#define EWOULDBLOCK
Definition: errno.h:42
#define ECONNRESET
Definition: errno.h:115
#define AF_INET
Definition: tcpip.h:117
#define inet_ntoa(addr)
Definition: inet.h:100
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define ntohs(x)
Definition: module.h:208
const char * strerror(int err)
Definition: compat_str.c:23
#define errno
Definition: errno.h:18
void adns__warn(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:94
int adns__vbuf_ensure(vbuf *vb, int want)
Definition: general.c:116
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
Definition: general.c:102
#define DNS_MAXUDP
Definition: internal.h:73
static int errno_resources(int e)
Definition: internal.h:707
#define DNS_PORT
Definition: internal.h:72
void adns__procdgram(adns_state ads, const byte *dgram, int len, int serv, int viatcp, struct timeval now)
Definition: reply.c:36
int tcprecv_skip
Definition: internal.h:300
struct adns__state::server servers[MAXSERVERS]
int tcpserver
Definition: internal.h:300
int avail
Definition: internal.h:111
int used
Definition: internal.h:111
byte * buf
Definition: internal.h:112

Referenced by adns__fdevents().

◆ adns_processtimeouts()

ADNS_API void adns_processtimeouts ( adns_state  ads,
const struct timeval now 
)

Definition at line 299 of file event.c.

299 {
300 struct timeval tv_buf;
301
304 if (now) adns__timeouts(ads, 1, 0,0, *now);
306}

Referenced by adns_afterselect(), and adns_processany().

◆ adns_processwriteable()

ADNS_API int adns_processwriteable ( adns_state  ads,
ADNS_SOCKET  fd,
const struct timeval now 
)

Definition at line 443 of file event.c.

443 {
444 int r;
445
447
448 switch (ads->tcpstate) {
449 case server_disconnected:
450 case server_broken:
451 break;
452 case server_connecting:
453 if (fd != ads->tcpsocket) break;
454 assert(ads->tcprecv.used==0);
456 for (;;) {
457 if (!adns__vbuf_ensure(&ads->tcprecv,1)) { r= ENOMEM; goto xit; }
461 if (r==0 || (r<0 && (errno==EAGAIN || errno==EWOULDBLOCK))) {
463 r= 0; goto xit;
464 }
465 if (r>0) {
466 adns__tcp_broken(ads,"connect/adns_socket_read","sent data before first request");
467 r= 0; goto xit;
468 }
469 if (errno==EINTR) continue;
470 if (errno_resources(errno)) { r= errno; goto xit; }
471 adns__tcp_broken(ads,"connect/adns_socket_read",strerror(errno));
472 r= 0; goto xit;
473 } /* not reached */
474 case server_ok:
475 if (fd != ads->tcpsocket) break;
476 while (ads->tcpsend.used) {
482 if (r<0) {
483 if (errno==EINTR) continue;
484 if (errno==EAGAIN || errno==EWOULDBLOCK) { r= 0; goto xit; }
485 if (errno_resources(errno)) { r= errno; goto xit; }
486 adns__tcp_broken(ads,"adns_socket_write",strerror(errno));
487 r= 0; goto xit;
488 } else if (r>0) {
489 ads->tcpsend.used -= r;
491 }
492 }
493 r= 0;
494 goto xit;
495 default:
496 abort();
497 }
498 r= 0;
499xit:
501 return r;
502}
#define adns_socket_write(sck, data, len)
Definition: adns_win32.h:101
static void tcp_connected(adns_state ads, struct timeval now)
Definition: event.c:78
void adns__sigpipe_protect(adns_state ads)
Definition: general.c:340
void adns__sigpipe_unprotect(adns_state ads)
Definition: general.c:360

Referenced by adns__fdevents().

◆ adns_rr_info()

ADNS_API adns_status adns_rr_info ( adns_rrtype  type,
const char **  rrtname_r,
const char **  fmtname_r,
int len_r,
const void datap,
char **  data_r 
)

Definition at line 186 of file general.c.

189 {
190 const typeinfo *typei;
191 vbuf vb;
192 adns_status st;
193
194 typei= adns__findtype(type);
195 if (!typei) return adns_s_unknownrrtype;
196
197 if (rrtname_r) *rrtname_r= typei->rrtname;
198 if (fmtname_r) *fmtname_r= typei->fmtname;
199 if (len_r) *len_r= typei->rrsz;
200
201 if (!datap) return adns_s_ok;
202
203 adns__vbuf_init(&vb);
204 st= typei->convstring(&vb,datap);
205 if (st) goto x_freevb;
206 if (!adns__vbuf_append(&vb,(byte*)"",1)) { st= adns_s_nomemory; goto x_freevb; }
207 assert((int)strlen((char*)vb.buf) == vb.used-1);
208 *data_r= realloc(vb.buf, (size_t) vb.used);
209 if (!*data_r) *data_r= (char*)vb.buf;
210 return adns_s_ok;
211
212 x_freevb:
213 adns__vbuf_free(&vb);
214 return st;
215}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define realloc
Definition: debug_ros.c:6
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int adns__vbuf_append(vbuf *vb, const byte *data, int len)
Definition: general.c:131
void adns__vbuf_init(vbuf *vb)
Definition: general.c:112
const typeinfo * adns__findtype(adns_rrtype type)
Definition: types.c:1025
adns_status(* convstring)(vbuf *vb, const void *data)
Definition: internal.h:135
const char * rrtname
Definition: internal.h:126
const char * fmtname
Definition: internal.h:127
int rrsz
Definition: internal.h:128
Definition: internal.h:110

Referenced by main(), print_dnsfail(), and query_done().

◆ adns_strerror()

ADNS_API const char * adns_strerror ( adns_status  st)

Definition at line 268 of file general.c.

268 {
269 const struct sinfo *si;
270
271 si= findsinfo(st);
272 return si->string;
273}
const char * string
Definition: general.c:223

Referenced by adns__diag_domain(), csp_hostaddr(), dumptype(), failure_status(), main(), print_dnsfail(), and print_status().

◆ adns_submit()

ADNS_API int adns_submit ( adns_state  ads,
const char owner,
adns_rrtype  type,
adns_queryflags  flags,
void context,
adns_query query_r 
)

Definition at line 204 of file query.c.

209 {
210 int r, ol, ndots;
212 const typeinfo *typei;
213 struct timeval now;
214 adns_query qu;
215 const char *p;
216
218
219 typei= adns__findtype(type);
220 if (!typei) return ENOSYS;
221
222 r= gettimeofday(&now,0); if (r) goto x_errno;
223 qu= query_alloc(ads,typei,flags,now); if (!qu) goto x_errno;
224
225 qu->ctx.ext= context;
226 qu->ctx.callback= 0;
227 memset(&qu->ctx.info,0,sizeof(qu->ctx.info));
228
229 *query_r= qu;
230
231 ol= strlen(owner);
232 if (!ol) { stat= adns_s_querydomaininvalid; goto x_adnsfail; }
233 if (ol>DNS_MAXDOMAIN+1) { stat= adns_s_querydomaintoolong; goto x_adnsfail; }
234
235 if (ol>=1 && owner[ol-1]=='.' && (ol<2 || owner[ol-2]!='\\')) {
236 flags &= ~adns_qf_search;
237 qu->flags= flags;
238 ol--;
239 }
240
241 if (flags & adns_qf_search) {
242 r= adns__vbuf_append(&qu->search_vb,(byte*)owner,ol);
243 if (!r) { stat= adns_s_nomemory; goto x_adnsfail; }
244
245 for (ndots=0, p=owner; (p= strchr(p,'.')); p++, ndots++);
246 qu->search_doneabs= (ndots >= ads->searchndots) ? -1 : 0;
247 qu->search_origlen= ol;
249 } else {
250 if (flags & adns_qf_owner) {
251 if (!save_owner(qu,owner,ol)) { stat= adns_s_nomemory; goto x_adnsfail; }
252 }
253 query_simple(ads,qu, owner,ol, typei,flags, now);
254 }
257 return 0;
258
259 x_adnsfail:
262 return 0;
263
264 x_errno:
265 r= errno;
266 assert(r);
268 return r;
269}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define stat
Definition: acwin.h:99
GLfloat GLfloat p
Definition: glext.h:8902
#define ENOSYS
Definition: errno.h:57
#define DNS_MAXDOMAIN
Definition: internal.h:75
static int save_owner(adns_query qu, const char *owner, int ol)
Definition: query.c:190
void adns__query_fail(adns_query qu, adns_status stat)
Definition: query.c:547
void adns__search_next(adns_state ads, adns_query qu, struct timeval now)
Definition: query.c:151
static void query_simple(adns_state ads, adns_query qu, const char *owner, int ol, const typeinfo *typei, adns_queryflags flags, struct timeval now)
Definition: query.c:127
static adns_query query_alloc(adns_state ads, const typeinfo *typei, adns_queryflags flags, struct timeval now)
Definition: query.c:41
#define memset(x, y, z)
Definition: compat.h:39
int searchndots
Definition: internal.h:300
Definition: http.c:7252
Definition: stat.h:55

Referenced by adns_submit_reverse_any(), adns_synchronous(), main(), query_do(), and readline().

◆ adns_submit_reverse()

ADNS_API int adns_submit_reverse ( adns_state  ads,
const struct sockaddr addr,
adns_rrtype  type,
adns_queryflags  flags,
void context,
adns_query query_r 
)

Definition at line 304 of file query.c.

309 {
310 if (type != adns_r_ptr && type != adns_r_ptr_raw) return EINVAL;
311 return adns_submit_reverse_any(ads,addr,"in-addr.arpa",type,flags,context,query_r);
312}
int adns_submit_reverse_any(adns_state ads, const struct sockaddr *addr, const char *zone, adns_rrtype type, adns_queryflags flags, void *context, adns_query *query_r)
Definition: query.c:271

Referenced by of_ptr(), and procaddr().

◆ adns_submit_reverse_any()

ADNS_API int adns_submit_reverse_any ( adns_state  ads,
const struct sockaddr addr,
const char rzone,
adns_rrtype  type,
adns_queryflags  flags,
void context,
adns_query query_r 
)

Definition at line 271 of file query.c.

277 {
278 const unsigned char *iaddr;
279 char *buf, *buf_free;
280 char shortbuf[100];
281 int r, lreq;
282
283 flags &= ~adns_qf_search;
284
285 if (addr->sa_family != AF_INET) return ENOSYS;
286 iaddr= (const unsigned char*) &(((const struct sockaddr_in*)addr) -> sin_addr);
287
288 lreq= strlen(zone) + 4*4 + 1;
289 if (lreq > (int)sizeof(shortbuf)) {
290 buf= malloc( strlen(zone) + 4*4 + 1 );
291 if (!buf) return errno;
292 buf_free= buf;
293 } else {
294 buf= shortbuf;
295 buf_free= 0;
296 }
297 sprintf(buf, "%d.%d.%d.%d.%s", iaddr[3], iaddr[2], iaddr[1], iaddr[0], zone);
298
300 free(buf_free);
301 return r;
302}
#define malloc
Definition: debug_ros.c:4
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD zone
Definition: sec_mgr.c:1754
int adns_submit(adns_state ads, const char *owner, adns_rrtype type, adns_queryflags flags, void *context, adns_query *query_r)
Definition: query.c:204
Definition: dhcpd.h:125

Referenced by adns_submit_reverse(), and of_reverse().

◆ adns_synchronous()

ADNS_API int adns_synchronous ( adns_state  ads,
const char owner,
adns_rrtype  type,
adns_queryflags  flags,
adns_answer **  answer_r 
)

Definition at line 314 of file query.c.

318 {
319 adns_query qu;
320 int r;
321
322 r= adns_submit(ads,owner,type,flags,0,&qu);
323 if (r) return r;
324
325 r= adns_wait(ads,&qu,answer_r,0);
326 if (r) adns_cancel(qu);
327
328 return r;
329}
ADNS_API int adns_wait(adns_state ads, adns_query *query_io, adns_answer **answer_r, void **context_r)
Definition: event.c:696
void adns_cancel(adns_query qu)
Definition: query.c:430

Referenced by Query_Main().

◆ adns_wait()

ADNS_API int adns_wait ( adns_state  ads,
adns_query query_io,
adns_answer **  answer_r,
void **  context_r 
)

Definition at line 696 of file event.c.

699 {
700 int r, maxfd, rsel;
701 fd_set readfds, writefds, exceptfds;
702 struct timeval tvbuf, *tvp;
703
704 adns__consistency(ads,*query_io,cc_entex);
705 for (;;) {
706 r= adns__internal_check(ads,query_io,answer_r,context_r);
707 if (r != EAGAIN) break;
708 maxfd= 0; tvp= 0;
709 FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
710 adns_beforeselect(ads,&maxfd,&readfds,&writefds,&exceptfds,&tvp,&tvbuf,0);
711 assert(tvp);
713 rsel= select(maxfd,&readfds,&writefds,&exceptfds,tvp);
715 if (rsel==-1) {
716 if (errno == EINTR) {
717 if (ads->iflags & adns_if_eintr) { r= EINTR; break; }
718 } else {
719 adns__diag(ads,-1,0,"select failed in wait: %s",strerror(errno));
721 }
722 } else {
723 assert(rsel >= 0);
724 adns_afterselect(ads,maxfd,&readfds,&writefds,&exceptfds,0);
725 }
726 }
728 return r;
729}
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds, const fd_set *writefds, const fd_set *exceptfds, const struct timeval *now)
Definition: event.c:595
void adns_beforeselect(adns_state ads, int *maxfd_io, fd_set *readfds_io, fd_set *writefds_io, fd_set *exceptfds_io, struct timeval **tv_mod, struct timeval *tv_tobuf, const struct timeval *now)
Definition: event.c:562
void adns_globalsystemfailure(adns_state ads)
Definition: event.c:619
adns_initflags iflags
Definition: internal.h:292
Definition: winsock.h:66
#define FD_ZERO(set)
Definition: winsock.h:96

Referenced by adns_synchronous(), main(), and proclog().

◆ adns_wait_poll()

ADNS_API int adns_wait_poll ( adns_state  ads,
adns_query query_io,
adns_answer **  answer_r,
void **  context_r 
)

Referenced by main(), and proclog().