dns.h File Reference

#include "../../config.h"
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
#include <arpa/inet.h>

Include dependency graph for dns.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define _DNS_H   1
#define SPF_PACKETSZ   8192
#define SPF_MAXDNAME   1025
#define SPF_MAXCDNAME   255
#define xgethostbyname(a, b, c, d, e)   gethostbyname((a))
#define xgethostbyname_free()

Functions

void _DNS_gethostbyname_r_free (void)
char * DNS_query (peer_info_t *, const char *, const int T_TYPE, const char *)
 Execute a DNS query.
char * DNS_txt_answer (int16_t, const u_char *, const u_char *, u_char *, char *, int *)
 Process a DNS message of type T_TXT.
char * DNS_mx_answer (int16_t, const u_char *, const u_char *, u_char *, char *, int *)
 Process a DNS message of type T_MX.
SPF_BOOL DNS_ptr_answer (peer_info_t *, int16_t, const u_char *, const u_char *, u_char *, char *, const char *, int *)
 Process a DNS message of type T_PTR.
char * DNS_cname_answer (int16_t, const u_char *, const u_char *, u_char *, char *, int *)
 Process a DNS message of type T_MX.
SPF_BOOL DNS_check_client_reverse (peer_info_t *)

Variables

int h_errno


Define Documentation

#define _DNS_H   1
 

Definition at line 46 of file dns.h.

#define SPF_MAXCDNAME   255
 

Definition at line 89 of file dns.h.

Referenced by DNS_check_client_reverse(), DNS_cname_answer(), DNS_mx_answer(), DNS_ptr_answer(), and DNS_txt_answer().

#define SPF_MAXDNAME   1025
 

Definition at line 88 of file dns.h.

Referenced by DNS_check_client_reverse(), and DNS_query().

#define SPF_PACKETSZ   8192
 

Definition at line 87 of file dns.h.

Referenced by DNS_check_client_reverse(), and DNS_query().

#define xgethostbyname a,
b,
c,
d,
 )     gethostbyname((a))
 

Definition at line 121 of file dns.h.

Referenced by UTIL_a_cmp(), and UTIL_validate_hostname().

 
#define xgethostbyname_free  ) 
 

Definition at line 122 of file dns.h.

Referenced by UTIL_a_cmp(), and UTIL_validate_hostname().


Function Documentation

void _DNS_gethostbyname_r_free void   ) 
 

SPF_BOOL DNS_check_client_reverse peer_info_t  ) 
 

Definition at line 975 of file dns.c.

References peer_info_t, peer_info_s::r_ip, peer_info_s::r_vhname, SPF_BOOL, SPF_FALSE, SPF_MAXCDNAME, SPF_MAXDNAME, SPF_PACKETSZ, SPF_TRUE, UTIL_rev_addr(), UTIL_validate_hostname(), xepprintf, xeprintf, xfree, xpprintf, xstrndup, and xvprintf.

Referenced by MACRO_process().

Here is the call graph for this function:

char* DNS_cname_answer int16_t  ancount,
const u_char *  msg_ptr,
const u_char *  eom_ptr,
u_char *  rd_ptr,
char *  buf,
int *  ttl
 

Process a DNS message of type T_MX.

Parameters:
ancount Answer count
msg_ptr DNS message
eom_ptr Pointer to the end of the DNS message
rd_ptr Pointer to a position in the DNS message
buf Utiltiy buffer
ttl Time To Live value of the DNS message
Author: Teddy <teddy@teddy.ch>

Date: 29/04/04
Date: 02/20/04 - Added cache by Travis Anderson <tanderson@codeshare.ca>

Desc:
SPF_PACKETSZ bytes are allocated and then filled with chars. This buffer is then used in a TXT DNS query using data from the passed peer_info_t structure. Upon success this buffer is re-cast as a char * and then a pointer to this memory is returned. Upon failure a NULL pointer is returned. Definition at line 866 of file dns.c.

References h_errno, SPF_MAXCDNAME, xepprintf, xmalloc, xpprintf, xrealloc, and xvprintf.

Referenced by DNS_query().

char* DNS_mx_answer int16_t  ancount,
const u_char *  msg_ptr,
const u_char *  eom_ptr,
u_char *  rd_ptr,
char *  buf,
int *  ttl
 

Process a DNS message of type T_MX.

Parameters:
ancount Answer count
msg_ptr DNS message
eom_ptr Pointer to the end of the DNS message
rd_ptr Pointer to a position in the DNS message
buf Utiltiy buffer
ttl Time To Live value of the DNS message
Author: James Couzens <jcouzens@codeshare.ca>

Date: 01/02/04
Date: 02/20/04 - Added cache by Travis Anderson <tanderson@codeshare.ca>

Desc: SPF_PACKETSZ bytes are allocated and then filled with chars. This buffer is then used in an MX DNS query using data from the passed peer_info_t structure. Upon success this buffer is re-cast as a char * and then a pointer to this memory is returned. Upon failure a NULL pointer is returned. Definition at line 611 of file dns.c.

References h_errno, SPF_MAXCDNAME, xmalloc, xprintf, xrealloc, and xvprintf.

Referenced by DNS_query().

SPF_BOOL DNS_ptr_answer peer_info_t p,
int16_t  ancount,
const u_char *  msg_ptr,
const u_char *  eom_ptr,
u_char *  rd_ptr,
char *  buf,
const char *  mta,
int *  ttl
 

Process a DNS message of type T_PTR.

Parameters:
p Global information structure containing client information
ancount Answer count
msg_ptr DNS message
eom_ptr Pointer to the end of the DNS message
rd_ptr Pointer to a position in the DNS message
buf Utiltiy buffer
mta IP address of the authoritative MX
ttl Time To Live value of the DNS message
Author: James Couzens <jcouzens@codeshare.ca>

Date: 01/02/04
Date: 02/20/04 - Added cache by Travis Anderson <tanderson@codeshare.ca>

Desc: A reverse lookup on an IP address leads to a lookup per returned PTR answer to see if the returned answer matches. The forward lookups are handled by a separate function which calls gethostbyname. Upon a single successful match of a forward lookup with a reverse lookup, returns SPF_TRUE. Returns SPF_FALSE upon failure. Definition at line 716 of file dns.c.

References h_errno, peer_info_t, SPF_BOOL, SPF_FALSE, SPF_MAXCDNAME, SPF_TRUE, UTIL_validate_hostname(), xepprintf, and xvprintf.

Referenced by DNS_query().

Here is the call graph for this function:

char* DNS_query peer_info_t p,
const char *  s,
const int  T_TYPE,
const char *  mta
 

Execute a DNS query.

Parameters:
p Global information structure containing client information
s Domain name with which to perform the query against
T_TYPE Type of DNS record to lookup (eg: T_TXT, T_PTR, T_A, etc..)
mta Used by DNS_ptr_answer in validation of an SPF ptr mechanism
Author: James Couzens <jcouzens@codeshare.ca>
Author: Travis Anderson <tanderson@codeshare.ca>

Date: 12/10/03
Date: 02/20/04 - Added cache by Travis Anderson <tanderson@codeshare.ca>

Desc: Executes a DNS query of type T_TYPE and then calls the appropriate answer parsing function based on that type. Returns a pointer to allocated memory (a string of space delimited records). Upon failure returns NULL. Definition at line 217 of file dns.c.

References DNS_cname_answer(), DNS_mx_answer(), DNS_ptr_answer(), DNS_txt_answer(), peer_info_s::error, h_errno, peer_info_t, SPF_ERROR, SPF_FALSE, SPF_MAX_ERROR, SPF_MAXDNAME, SPF_NONE, SPF_PACKETSZ, SPF_TRUE, UTIL_assoc_prefix(), xepprintf, xprintf, and xvprintf.

Referenced by SPF_parse_policy(), SPF_policy_main_rec(), UTIL_mx_cmp(), UTIL_ptr_cmp(), and UTIL_validate_ptr().

Here is the call graph for this function:

char* DNS_txt_answer int16_t  ancount,
const u_char *  msg_ptr,
const u_char *  eom_ptr,
u_char *  rd_ptr,
char *  buf,
int *  ttl
 

Process a DNS message of type T_TXT.

Parameters:
ancount Answer count
msg_ptr DNS message
eom_ptr Pointer to the end of the DNS message
rd_ptr Pointer to a position in the DNS message
buf Utiltiy buffer
ttl Time To Live value of the DNS message
Author: James Couzens <jcouzens@codeshare.ca>

Date: 01/02/04
Date: 02/23/04 - Bugfix from Albert Weichselbraun <albert@atnet.at>
Date: 02/20/04 - Added cache by Travis Anderson <tanderson@codeshare.ca>

Desc: SPF_PACKETSZ bytes are allocated and then filled with chars. This buffer is then used in a TXT DNS query using data from the passed peer_info_t structure. Upon success this buffer is re-cast as a char * and then a pointer to this memory is returned. Upon failure a NULL pointer is returned. Definition at line 419 of file dns.c.

References h_errno, SPF_MAX_STR, SPF_MAXCDNAME, xepprintf, xfree, xmalloc, xpprintf, xrealloc, xstrndup, and xvprintf.

Referenced by DNS_query().


Variable Documentation

int h_errno
 

Definition at line 59 of file main.c.

Referenced by DNS_cname_answer(), DNS_mx_answer(), DNS_ptr_answer(), DNS_query(), and DNS_txt_answer().


Generated on Thu Sep 16 18:10:47 2004 for libSPF v1.0 by doxygen 1.3.8