#define RDLENGTH_SIZE (size_t)2
#define ANSWER_FIXED_SIZE (TYPE_SIZE + CLASS_SIZE + TTL_SIZE + RDLENGTH_SIZE)
-typedef enum
-{
- REQ_IDLE, /* We're doing not much at all */
- REQ_PTR, /* Looking up a PTR */
- REQ_A, /* Looking up an A or AAAA */
- REQ_CNAME /* We got a CNAME in response, we better get a real answer next */
-} request_state;
-
struct reslist
{
rb_dlink_node node;
int id;
int sent; /* number of requests sent */
- request_state state; /* State the resolver machine is in */
time_t ttl;
char type;
char queryname[128]; /* name currently being queried */
char retries; /* retry counter */
char sends; /* number of sends (>1 means resent) */
- char resend; /* send flag. 0 == dont resend */
time_t sentat;
time_t timeout;
struct rb_sockaddr_storage addr;
static struct reslist *find_id(int id);
static struct DNSReply *make_dnsreply(struct reslist *request);
-extern struct rb_sockaddr_storage irc_nsaddr_list[IRCD_MAXNS];
-extern int irc_nscount;
-extern char irc_domain[HOSTLEN + 1];
-
-
/*
* int
* res_ourserver(inp)
request->sentat = rb_current_time();
request->retries = 3;
- request->resend = 1;
request->timeout = 4; /* start at 4 and exponential inc. */
request->query = query;
- request->state = REQ_IDLE;
rb_dlinkAdd(request, &request->node, &request_list);
request = make_request(query);
request->name = (char *)rb_malloc(strlen(host_name) + 1);
strcpy(request->name, host_name);
- request->state = REQ_A;
}
rb_strlcpy(request->queryname, host_name, sizeof(request->queryname));
static void resend_query(struct reslist *request)
{
- if (request->resend == 0)
- return;
-
switch (request->type)
{
case T_PTR:
return (1);
break;
- case T_CNAME: /* first check we already havent started looking
- into a cname */
- if (request->type != T_PTR)
- return (0);
-
- if (request->state == REQ_CNAME)
- {
- n = irc_dn_expand((unsigned char *)buf, (unsigned char *)eob,
- current, hostbuf, sizeof(hostbuf));
-
- if (n < 0)
- return (0);
- return (1);
- }
-
- request->state = REQ_CNAME;
+ case T_CNAME:
+ /* real answer will follow */
current += rd_length;
break;