# pdns.h File Reference

`#include <ptlib/sockets.h>`
`#include <ptclib/random.h>`
`#include <ptclib/url.h>`
`#include <arpa/nameser.h>`
`#include <resolv.h>`

Go to the source code of this file.

## Namespaces

namespace | PDNS

## Classes

struct | _DnsAData
struct | _DnsAAAAData
struct | DNS_MX_DATA
struct | DNS_PTR_DATA
struct | _DnsSRVData
struct | _DnsNULLData
struct | _DnsRecordFlags
class | DnsRecord
class | PDNS::SRVRecord
class | MXRecord

## Defines

#define | P_HAS_RESOLVER 1
#define | T_SRV 33
#define | T_NAPTR 35
#define | DNS_STATUS int
#define | DNS_TYPE_SRV T_SRV
#define | DNS_TYPE_MX T_MX
#define | DNS_TYPE_A T_A
#define | DNS_TYPE_AAAA T_AAAA
#define | DNS_TYPE_NAPTR T_NAPTR
#define | DnsFreeRecordList 1
#define | DNS_QUERY_STANDARD 0
#define | DNS_QUERY_BYPASS_CACHE 0

## Typedefs

typedef _DnsAData | DNS_A_DATA
typedef _DnsAAAAData | DNS_AAAA_DATA
typedef _DnsSRVData | DNS_SRV_DATA
typedef _DnsNULLData | DNS_NULL_DATA
typedef _DnsRecordFlags | DNS_RECORD_FLAGS
typedef enum _DnsSection | DNS_SECTION
typedef DnsRecord | DNS_RECORD
typedef DnsRecord * | PDNS_RECORD

## Enumerations

enum | _DnsSection { DnsSectionQuestion, DnsSectionAnswer, DnsSectionAuthority, DnsSectionAdditional }

## Functions

void | DnsRecordListFree (PDNS_RECORD rec, int FreeType)
PDNS_RECORD | DnsRecordSetCopy (PDNS_RECORD src)
DNS_STATUS | DnsQuery_A (const char *service, WORD requestType, DWORD options, void *, PDNS_RECORD *results, void *)
DNS_STATUS | PDNS::Cached_DnsQuery (const char *name, WORD type, DWORD options, void *extra, PDNS_RECORD *queryResults, void *reserved)
template<unsigned type, class RecordListType, class RecordType>
PBoolean | PDNS::Lookup (const PString &name, RecordListType &recordList)
void | PDNS::PrintOn (ostream &strm) const
SRVRecord * | PDNS::GetFirst ()
SRVRecord * | PDNS::GetNext ()
PDNS::NAPTRRecord * | PDNS::HandleDNSRecord (PDNS_RECORD dnsRecord, PDNS_RECORD results)
PBoolean | GetRecords (const PString &service, SRVRecordList &serviceList)
| return a list of DNS SRV record with the specified service type
PBoolean | GetSRVRecords (const PString &service, SRVRecordList &serviceList)
| provided for backwards compatibility
PBoolean | GetSRVRecords (const PString &service, const PString &type, const PString &domain, SRVRecordList &serviceList)
| return a list of DNS SRV record with the specified service, type and domain
PBoolean | LookupSRV (const PString &srvQuery, WORD defaultPort, PIPSocketAddressAndPortVector &addrList)
| Perform a DNS lookup of the specified service.
PBoolean | LookupSRV (const PString &domain, const PString &service, WORD defaultPort, PIPSocketAddressAndPortVector &addrList)
PBoolean | LookupSRV (const PURL &url, const PString &service, PStringList &returnStr)
void | PrintOn (ostream &strm) const
MXRecord * | GetFirst ()
MXRecord * | GetNext ()
PDNS::MXRecord * | HandleDNSRecord (PDNS_RECORD dnsRecord, PDNS_RECORD results)
PBoolean | GetRecords (const PString &domain, MXRecordList &serviceList)
| return a list of MX records for the specified domain
PBoolean | GetMXRecords (const PString &domain, MXRecordList &serviceList)
| provided for backwards compatibility

## Variables

PINDEX | PDNS::priPos
PWORDArray | PDNS::priList
PINDEX | lastIndex

## Define Documentation

#define DNS_QUERY_BYPASS_CACHE 0

#define DNS_QUERY_STANDARD 0

#define DNS_STATUS int

#define DNS_TYPE_A T_A

#define DNS_TYPE_AAAA T_AAAA

#define DNS_TYPE_MX T_MX

#define DNS_TYPE_NAPTR T_NAPTR

#define DNS_TYPE_SRV T_SRV

#define DnsFreeRecordList 1

#define P_HAS_RESOLVER 1

#define T_NAPTR 35

#define T_SRV 33

## Typedef Documentation

typedef struct _DnsAData DNS_A_DATA

typedef struct _DnsAAAAData DNS_AAAA_DATA

typedef struct _DnsNULLData DNS_NULL_DATA

typedef DnsRecord DNS_RECORD

typedef struct _DnsRecordFlags DNS_RECORD_FLAGS

typedef enum _DnsSection DNS_SECTION

typedef struct _DnsSRVData DNS_SRV_DATA

typedef DnsRecord* PDNS_RECORD

## Enumeration Type Documentation

enum _DnsSection

Enumerator:

  DnsSectionQuestion |
  DnsSectionAnswer |
  DnsSectionAuthority |
  DnsSectionAdditional |

## Function Documentation

DNS_STATUS DnsQuery_A | ( | const char * | service,
|  | WORD | requestType,
|  | DWORD | options,
|  | void * | ,
|  | PDNS_RECORD * | results,
|  | void * |  |
| ) |  |  |

void DnsRecordListFree | ( | PDNS_RECORD | rec,
|  | int | FreeType |
| ) |  |  |

PDNS_RECORD DnsRecordSetCopy | ( | PDNS_RECORD | src | ) |

MXRecord* GetFirst | ( |  | ) |

PBoolean GetMXRecords | ( | const PString & | domain,
|  | MXRecordList & | serviceList |
| ) |  |  | `[inline, protected]`

provided for backwards compatibility

MXRecord* GetNext | ( |  | ) |

PBoolean GetRecords | ( | const PString & | domain,
|  | MXRecordList & | serviceList |
| ) |  |  | `[inline, protected]`

return a list of MX records for the specified domain

PBoolean GetRecords | ( | const PString & | service,
|  | SRVRecordList & | serviceList |
| ) |  |  | `[inline]`

return a list of DNS SRV record with the specified service type

PBoolean GetSRVRecords | ( | const PString & | service,
|  | const PString & | type,
|  | const PString & | domain,
|  | SRVRecordList & | serviceList |
| ) |  |  |

return a list of DNS SRV record with the specified service, type and domain

PBoolean GetSRVRecords | ( | const PString & | service,
|  | SRVRecordList & | serviceList |
| ) |  |  | `[inline]`

provided for backwards compatibility

PDNS::MXRecord* HandleDNSRecord | ( | PDNS_RECORD | dnsRecord,
|  | PDNS_RECORD | results |
| ) |  |  |

PBoolean LookupSRV | ( | const PURL & | url,
|  | const PString & | service,
|  | PStringList & | returnStr |
| ) |  |  |

Parameters:

  url | URL to lookup
  service | service to use
  returnStr | resolved addresses, if return value is true

PBoolean LookupSRV | ( | const PString & | domain,
|  | const PString & | service,
|  | WORD | defaultPort,
|  | PIPSocketAddressAndPortVector & | addrList |
| ) |  |  |

Parameters:

  domain | domain to lookup
  service | service to use
  defaultPort | default por to use
  addrList | returned list of sockets and ports

PBoolean LookupSRV | ( | const PString & | srvQuery,
|  | WORD | defaultPort,
|  | PIPSocketAddressAndPortVector & | addrList |
| ) |  |  |

Perform a DNS lookup of the specified service.

Returns:
  true if the service could be resolved, else false

void PrintOn | ( | ostream & | strm | ) | const

## Variable Documentation

PINDEX lastIndex