41# include <netinet/in.h>
42# include <arpa/inet.h>
65 if (what)
adns__warn(
ads,serv,0,
"TCP connection failed: %s: %s",what,why);
69 for (qu=
ads->tcpw.head; qu; qu= qu->
next)
83 for (qu=
ads->tcpw.head; qu &&
ads->
tcpstate == server_ok; qu= nqu) {
98 case server_connecting:
102 case server_disconnected:
168 if (!rbuf) { *tv_io= rbuf= tvbuf; }
180 *tvbuf= maxto; *tv_io= tvbuf;
182 if (
timercmp(rbuf,&maxto,>)) *rbuf= maxto;
210 for (qu=
queue->head; qu; qu= nqu) {
217 if (qu->
state != query_tosend) {
236 for (qu=
ads->tcpw.head; qu; qu= nqu) {
245 case server_disconnected:
246 if (!
ads->tcpw.head)
return;
251 if (
ads->tcpw.head)
return;
257 case server_connecting:
264 case server_connecting:
318 pollfds_buf[0].events=
POLLIN;
319 pollfds_buf[0].revents= 0;
322 case server_disconnected:
325 case server_connecting:
326 pollfds_buf[1].events=
POLLOUT;
339 int want, dgramlen,
r, udpaddrlen, serv, old_skip;
346 case server_disconnected:
348 case server_connecting:
397 udpaddrlen=
sizeof(udpaddr);
400 (
struct sockaddr*)&udpaddr,&udpaddrlen);
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));
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);
421 adns__diag(
ads,-1,0,
"datagram received from wrong port %u (expected %u)",
427 ads->
servers[serv].addr.s_addr != udpaddr.sin_addr.s_addr;
430 adns__warn(
ads,-1,0,
"datagram received from unknown nameserver %s",
449 case server_disconnected:
452 case server_connecting:
507 case server_disconnected:
510 case server_connecting:
523 int revent,
int pollflag,
524 int maxfd,
const fd_set *fds,
529 if (!(revent & pollflag))
return;
530 if (fds && !((
int)
fd<maxfd &&
FD_ISSET(
fd,fds)))
return;
543 const struct pollfd *pollfds,
int npollfds,
544 int maxfd,
const fd_set *readfds,
550 for (
i=0;
i<npollfds;
i++) {
552 if ((
int)
fd >= maxfd) maxfd=
fd+1;
568 int i, maxfd, npollfds;
573 if (tv_mod && (!*tv_mod || (*tv_mod)->
tv_sec || (*tv_mod)->tv_usec)) {
582 for (
i=0;
i<npollfds;
i++) {
584 if ((
int)
fd >= maxfd) maxfd=
fd+1;
611 maxfd,readfds,writefds,exceptfds,
626 case server_connecting:
630 case server_disconnected:
680 }
else if (
ads->udpw.head ||
ads->tcpw.head) {
690 if (context_r) *context_r= qu->
ctx.
ext;
701 fd_set readfds, writefds, exceptfds;
713 rsel=
select(maxfd,&readfds,&writefds,&exceptfds,tvp);
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
#define adns_socket_write(sck, data, len)
#define adns_socket_read(sck, data, len)
#define adns_socket_close(sck)
#define gettimeofday(tv, tz)
#define ADNS_CAPTURE_ERRNO
#define timercmp(tvp, uvp, cmp)
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
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)
LPPROTOENT WSAAPI getprotobyname(IN CONST CHAR FAR *name)
GLdouble GLdouble GLdouble r
GLenum const GLvoid * addr
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
_Check_return_ ldiv_t __cdecl ldiv(_In_ long _Numerator, _In_ long _Denominator)
#define memmove(s1, s2, n)
const char * strerror(int err)
#define LIST_UNLINK(list, node)
int adns_processexceptional(adns_state ads, ADNS_SOCKET fd, const struct timeval *now)
void adns__timeouts(adns_state ads, int act, struct timeval **tv_io, struct timeval *tvbuf, struct timeval now)
static void inter_maxto(struct timeval **tv_io, struct timeval *tvbuf, struct timeval maxto)
void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds, const fd_set *writefds, const fd_set *exceptfds, const struct timeval *now)
int adns_check(adns_state ads, adns_query *query_io, adns_answer **answer_r, void **context_r)
static void fd_event(adns_state ads, ADNS_SOCKET fd, int revent, int pollflag, int maxfd, const fd_set *fds, int(*func)(adns_state, ADNS_SOCKET fd, const struct timeval *now), struct timeval now, int *r_r)
static void timeouts_queue(adns_state ads, int act, struct timeval **tv_io, struct timeval *tvbuf, struct timeval now, struct query_queue *queue)
static void tcp_close(adns_state ads)
void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io, struct timeval *tv_buf)
int adns_wait(adns_state ads, adns_query *query_io, adns_answer **answer_r, void **context_r)
static void inter_maxtoabs(struct timeval **tv_io, struct timeval *tvbuf, struct timeval now, struct timeval maxtime)
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)
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)
void adns__tcp_broken(adns_state ads, const char *what, const char *why)
static void inter_immed(struct timeval **tv_io, struct timeval *tvbuf)
void adns__autosys(adns_state ads, struct timeval now)
int adns_processany(adns_state ads)
static void tcp_connected(adns_state ads, struct timeval now)
int adns_processwriteable(adns_state ads, ADNS_SOCKET fd, const struct timeval *now)
void adns_globalsystemfailure(adns_state ads)
void adns_processtimeouts(adns_state ads, const struct timeval *now)
int adns__pollfds(adns_state ads, struct pollfd pollfds_buf[MAX_POLLFDS])
void adns__tcp_tryconnect(adns_state ads, struct timeval now)
int adns__internal_check(adns_state ads, adns_query *query_io, adns_answer **answer, void **context_r)
int adns_processreadable(adns_state ads, ADNS_SOCKET fd, const struct timeval *now)
static void tcp_events(adns_state ads, int act, struct timeval **tv_io, struct timeval *tvbuf, struct timeval now)
void adns_firsttimeout(adns_state ads, struct timeval **tv_io, struct timeval *tvbuf, struct timeval now)
void adns__sigpipe_protect(adns_state ads)
void adns__debug(adns_state ads, int serv, adns_query qu, const char *fmt,...)
void adns__sigpipe_unprotect(adns_state ads)
void adns__warn(adns_state ads, int serv, adns_query qu, const char *fmt,...)
int adns__vbuf_ensure(vbuf *vb, int want)
void adns__diag(adns_state ads, int serv, adns_query qu, const char *fmt,...)
void adns__querysend_tcp(adns_query qu, struct timeval now)
static int errno_resources(int e)
void adns__query_fail(adns_query qu, adns_status stat)
int adns__setnonblock(adns_state ads, ADNS_SOCKET fd)
void adns__query_send(adns_query qu, struct timeval now)
void adns__procdgram(adns_state ads, const byte *dgram, int len, int serv, int viatcp, struct timeval now)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
enum adns__query::@4223 state
enum adns__state::adns__tcpstate tcpstate
struct query_queue udpw tcpw childw output
struct timeval tcptimeout
struct adns__state::server servers[MAXSERVERS]
static void timevaladd(struct timeval *tv_io, long ms)
#define FD_ISSET(fd, set)