Back to index

opendkim  2.6.4
Classes | Defines | Functions | Variables
dkim-dns.c File Reference
#include <sys/param.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include "dkim.h"
#include "dkim-dns.h"
#include "build-config.h"

Go to the source code of this file.

Classes

struct  dkim_res_qh

Defines

#define _REENTRANT
#define MAXPACKET   8192

Functions

int dkim_res_cancel (void *srv, void *qh)
int dkim_res_query (void *srv, int type, unsigned char *query, unsigned char *buf, size_t buflen, void **qh)
int dkim_res_waitreply (void *srv, void *qh, struct timeval *to, size_t *bytes, int *error, int *dnssec)

Variables

static char dkim_dns_c_id [] = "@(#)$Id: dkim-dns.c,v 1.6.4.1 2010/10/27 21:43:08 cm-msk Exp $"

Class Documentation

struct dkim_res_qh

Definition at line 44 of file dkim-dns.c.

Class Members
size_t rq_buflen
int rq_dnssec
int rq_error

Define Documentation

#define _REENTRANT

Definition at line 13 of file dkim-dns.c.

#define MAXPACKET   8192

Definition at line 37 of file dkim-dns.c.


Function Documentation

int dkim_res_cancel ( void *  srv,
void *  qh 
)

Definition at line 68 of file dkim-dns.c.

{
       if (qh != NULL)
              free(qh);

       return 0;
}

Here is the caller graph for this function:

int dkim_res_query ( void *  srv,
int  type,
unsigned char *  query,
unsigned char *  buf,
size_t  buflen,
void **  qh 
)

Definition at line 98 of file dkim-dns.c.

{
       int n;
       int ret;
       struct dkim_res_qh *rq;
       unsigned char qbuf[HFIXEDSZ + MAXPACKET];
#ifdef HAVE_RES_NINIT
       struct __res_state statp;
#endif /* HAVE_RES_NINIT */

#ifdef HAVE_RES_NINIT
       memset(&statp, '\0', sizeof statp);
       res_ninit(&statp);
#endif /* HAVE_RES_NINIT */

#ifdef HAVE_RES_NINIT
       n = res_nmkquery(&statp, QUERY, (char *) query, C_IN, type, NULL, 0,
                        NULL, qbuf, sizeof qbuf);
#else /* HAVE_RES_NINIT */
       n = res_mkquery(QUERY, (char *) query, C_IN, type, NULL, 0, NULL, qbuf,
                       sizeof qbuf);
#endif /* HAVE_RES_NINIT */
       if (n == (size_t) -1)
       {
#ifdef HAVE_RES_NINIT
              res_nclose(&statp);
#endif /* HAVE_RES_NINIT */
              return DKIM_DNS_ERROR;
       }

#ifdef HAVE_RES_NINIT
       ret = res_nsend(&statp, qbuf, n, buf, buflen);
#else /* HAVE_RES_NINIT */
       ret = res_send(qbuf, n, buf, buflen);
#endif /* HAVE_RES_NINIT */
       if (ret == -1)
       {
#ifdef HAVE_RES_NINIT
              res_nclose(&statp);
#endif /* HAVE_RES_NINIT */
              return DKIM_DNS_ERROR;
       }

#ifdef HAVE_RES_NINIT
       res_nclose(&statp);
#endif /* HAVE_RES_NINIT */

       rq = (struct dkim_res_qh *) malloc(sizeof *rq);
       if (rq == NULL)
              return DKIM_DNS_ERROR;

       rq->rq_dnssec = DKIM_DNSSEC_UNKNOWN;
       if (ret == -1)
       {
              rq->rq_error = errno;
              rq->rq_buflen = 0;
       }
       else
       {
              rq->rq_error = 0;
              rq->rq_buflen = (size_t) ret;
       }

       *qh = (void *) rq;

       return DKIM_DNS_SUCCESS;
}

Here is the caller graph for this function:

int dkim_res_waitreply ( void *  srv,
void *  qh,
struct timeval *  to,
size_t *  bytes,
int *  error,
int *  dnssec 
)

Definition at line 186 of file dkim-dns.c.

{
       struct dkim_res_qh *rq;

       assert(qh != NULL);

       rq = qh;

       if (bytes != NULL)
              *bytes = rq->rq_buflen;
       if (error != NULL)
              *error = rq->rq_error;
       if (dnssec != NULL)
              *dnssec = rq->rq_dnssec;

       return DKIM_DNS_SUCCESS;
}

Here is the caller graph for this function:


Variable Documentation

char dkim_dns_c_id[] = "@(#)$Id: dkim-dns.c,v 1.6.4.1 2010/10/27 21:43:08 cm-msk Exp $" [static]

Definition at line 8 of file dkim-dns.c.