TDNSClient
From Ultibo.org
								
												
				Return to Unit DNS
Description
To be documented
Class definitions
TDNSClient = class(TNetworkClient)
 constructor Create(AProtocol:TNetworkProtocol);
 | 
|
 destructor Destroy; override;
 | 
|
private 
 | |
 FTlsIndex:LongWord;
 | 
|
 function GetClientData:PDNSClientData;
 | 
|
 function CreateClientData:Boolean;
 | 
|
 function GetLastAddrInfo(AAddrInfo:PAddrInfo):PAddrInfo;
 | 
|
 function AddressEntryToHostEnt(AddressEntry:TAddressEntry; const AName:String; ACount:Integer):PHostEnt;
 | 
|
 function HostEntryToHostEnt(HostEntry:THostEntry):PHostEnt;
 | 
|
 function NetworkEntryToNetEnt(NetworkEntry:TNetworkEntry):PNetEnt;
 | 
|
 function ServEntryToServEnt(ServEntry:TServEntry):PServEnt;
 | 
|
 function ProtoEntryToProtoEnt(ProtoEntry:TProtoEntry):PProtoEnt;
 | 
|
 function AddressEntryToAddrInfo(AddressEntry:TAddressEntry; AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word; AFirst:Boolean):PAddrInfo;
 | 
|
 function HostEntryToAddrInfo(HostEntry:THostEntry; AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word; AFirst:Boolean):PAddrInfo;
 | 
|
 function ResolveLocalAddrInfo(AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word):PAddrInfo;
 | 
|
 function ResolveLoopbackAddrInfo(AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word):PAddrInfo;
 | 
|
 function ResolveHostByName(const AName:String; AFamily:Integer):THostEntry;
 | 
|
 function ResolveHostByAddress(AAddress:Pointer; ALength,AFamily:Integer):THostEntry;
 | 
|
 function ResolveHostName:String;
 | 
|
 function ResolveServByName(const AName,AProto:String):TServEntry;
 | 
|
 function ResolveServByPort(APort:Integer; const AProto:String):TServEntry;
 | 
|
 function ResolveProtoByName(const AName:String):TProtoEntry;
 | 
|
 function ResolveProtoByNumber(AProto:Integer):TProtoEntry;
 | 
|
 function ResolveNetworkByName(const AName:String; AFamily:Integer):TNetworkEntry;
 | 
|
 function ResolveNetworkByAddress(AAddress:Pointer; ALength,AFamily:Integer):TNetworkEntry;
 | 
|
 function InAddrToName(const AAddress:TInAddr):String;
 | 
|
 function NameToInAddr(const AName:String):TInAddr;
 | 
|
 function In6AddrToName(const AAddress:TIn6Addr):String;
 | 
|
 function NameToIn6Addr(const AName:String):TIn6Addr;
 | 
|
 function GetDNSMessageSize(AMessage:PDNSMessage):Integer;
 | 
|
 function GetDNSNameSize(AMessage:PDNSMessage; AOffset:Word):Word;
 | 
|
 function GetDNSQuestionSize(AMessage:PDNSMessage; AOffset:Word):Word;
 | 
|
 function GetDNSResourceSize(AMessage:PDNSMessage; AOffset:Word):Word;
 | 
|
 function GetDNSQuestionOffset(AMessage:PDNSMessage; ACount:Word):Word;
 | 
|
 function GetDNSAnswerOffset(AMessage:PDNSMessage; ACount:Word):Word;
 | 
|
 function GetDNSAuthorityOffset(AMessage:PDNSMessage; ACount:Word):Word;
 | 
|
 function GetDNSAdditionalOffset(AMessage:PDNSMessage; ACount:Word):Word;
 | 
|
 function CreateDNSQuery(AMessage:PDNSMessage; AIdentifier:Word):Boolean;
 | 
|
 function CheckDNSResponse(AMessage:PDNSMessage; AIdentifier:Word):Boolean;
 | 
|
 function HandleDNSResponse(AMessage:PDNSMessage; AFamily,AIdentifier:Word):Boolean;
 | 
|
 function PerformDNSRequest(AData:Pointer; ALength,AFamily,AType,AClass:Word):Boolean;
 | 
|
 function SendDNSQuery(ASocket:TProtocolSocket; AServer:PSockAddr; AServerLength:Integer; AData:Pointer; ALength,AFamily,AType,AClass,AIdentifier:Word):Boolean;
 | 
|
 function RecvDNSResponse(ASocket:TProtocolSocket; AFamily,AType,AClass,AIdentifier:Word):Boolean;
 | 
|
 function InsertDNSName(AMessage:PDNSMessage; AOffset:Word; AName:Pointer; ALength:Word):Boolean;
 | 
|
 function ExtractDNSName(AMessage:PDNSMessage; AOffset:Word; AName:Pointer; var ALength:Word):Boolean;
 | 
|
 function ExtractDNSRData(AMessage:PDNSMessage; AOffset:Word; AData:Pointer; var ALength:Word; AType,AClass:Word):Boolean;
 | 
|
 function InsertDNSQuestion(AMessage:PDNSMessage; ACount:Word; AData:Pointer; ALength,AFamily,AType,AClass:Word):Boolean;
 | 
|
 function ExtractDNSAnswer(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength:Word; AFamily:Word; var AType,AClass:Word; var ATtl:LongWord):Boolean;
 | 
|
 function ExtractDNSAuthority(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength:Word; AFamily:Word; var AType,AClass:Word; var ATtl:LongWord):Boolean;
 | 
|
 function ExtractDNSAdditional(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength:Word; AFamily:Word; var AType,AClass:Word; var ATtl:LongWord):Boolean;
 | 
|
public 
 | |
 function GetHostByAddr(AAddr:Pointer; ALength,AFamily:Integer):PHostEnt;
 | 
|
 function GetHostByName(AName:PChar; AFamily:Integer):PHostEnt;
 | 
|
 function GetHostName(AName:PChar; ALength:Integer):Integer;
 | 
|
 function GetServByPort(APort:Integer; AProto:PChar):PServEnt;
 | 
|
 function GetServByName(AName,AProto:PChar):PServEnt;
 | 
|
 function GetProtoByNumber(AProto:Integer):PProtoEnt;
 | 
|
 function GetProtoByName(AName:PChar):PProtoEnt;
 | 
|
 function GetNetByAddr(AAddr:Pointer; ALength,AFamily:Integer):PNetEnt;
 | 
|
 function GetNetByName(AName:PChar; AFamily:Integer):PNetEnt;
 | 
|
 function GetAddrInfo(ANodeName,AServName:PChar; AHints:PAddrInfo; var AAddrInfo:PAddrInfo):Integer;
 | 
|
 function GetNameInfo(AAddr:PSockAddr; AAddrLength:Integer; AHost:PChar; AHostLength:Integer; AServ:PChar; AServLength:Integer; AFlags:LongWord):Integer;
 | 
|
 procedure FreeAddrInfo(AAddrInfo:PAddrInfo);
 | 
|
 function StartClient:Boolean; override;
 | 
|
 function StopClient:Boolean; override;
 | 
|
Function declarations
constructor TDNSClient.Create(AProtocol:TNetworkProtocol);
Description: To be documented
| Note | None documented | 
|---|
destructor TDNSClient.Destroy;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.GetClientData:PDNSClientData;
Description: Get the DNS client data for the current thread
| Note | None documented | 
|---|
function TDNSClient.CreateClientData:Boolean;
Description: Allocate the DNS client data for the current thread
| Note | None documented | 
|---|
function TDNSClient.GetLastAddrInfo(AAddrInfo:PAddrInfo):PAddrInfo;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.AddressEntryToHostEnt(AddressEntry:TAddressEntry; const AName:String; ACount:Integer):PHostEnt;
Description: To be documented
| Note | Caller must hold Address entry lock | 
|---|
function TDNSClient.HostEntryToHostEnt(HostEntry:THostEntry):PHostEnt;
Description: To be documented
| Note | Caller must hold Host entry lock | 
|---|
function TDNSClient.NetworkEntryToNetEnt(NetworkEntry:TNetworkEntry):PNetEnt;
Description: To be documented
| Note | Caller must hold Network entry lock | 
|---|
function TDNSClient.ServEntryToServEnt(ServEntry:TServEntry):PServEnt;
Description: To be documented
| Note | Caller must hold Serv entry lock | 
|---|
function TDNSClient.ProtoEntryToProtoEnt(ProtoEntry:TProtoEntry):PProtoEnt;
Description: To be documented
| Note | Caller must hold Proto entry lock | 
|---|
function TDNSClient.AddressEntryToAddrInfo(AddressEntry:TAddressEntry; AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word; AFirst:Boolean):PAddrInfo;
Description: To be documented
| Note | Caller must hold Address entry lock | 
|---|
function TDNSClient.HostEntryToAddrInfo(HostEntry:THostEntry; AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word; AFirst:Boolean):PAddrInfo;
Description: To be documented
| Note | Caller must hold Host entry lock | 
|---|
function TDNSClient.ResolveLocalAddrInfo(AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word):PAddrInfo;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.ResolveLoopbackAddrInfo(AFlags,AFamily,AProtocol,ASocketType:LongInt; APort:Word):PAddrInfo;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.ResolveHostByName(const AName:String; AFamily:Integer):THostEntry;
Description: Performs a DNS_TYPE_A or DNS_TYPE_AAAA Query for the Address of the Domain name supplied
| Note |  Caller must check if name is blank or 'localhost' and get the appropriate local addresses
 Will lock the returned host entry for read access, caller must unlock when finished.  | 
|---|
function TDNSClient.ResolveHostByAddress(AAddress:Pointer; ALength,AFamily:Integer):THostEntry;
Description: Performs a DNS_TYPE_PTR Query for the Domain name of the Address supplied
| Note |  Address will be in network order where applicable
 Will lock the returned host entry for read access, caller must unlock when finished.  | 
|---|
function TDNSClient.ResolveHostName:String;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.ResolveServByName(const AName,AProto:String):TServEntry;
Description: To be documented
| Note | Will lock the returned service entry for read access, caller must unlock when finished. | 
|---|
function TDNSClient.ResolveServByPort(APort:Integer; const AProto:String):TServEntry;
Description: To be documented
| Note |  Port will be in network order
 Will lock the returned service entry for read access, caller must unlock when finished.  | 
|---|
function TDNSClient.ResolveProtoByName(const AName:String):TProtoEntry;
Description: To be documented
| Note | Will lock the returned protocol entry for read access, caller must unlock when finished. | 
|---|
function TDNSClient.ResolveProtoByNumber(AProto:Integer):TProtoEntry;
Description: To be documented
| Note |  Protocol will be in host order
 Will lock the returned protocol entry for read access, caller must unlock when finished.  | 
|---|
function TDNSClient.ResolveNetworkByName(const AName:String; AFamily:Integer):TNetworkEntry;
Description: To be documented
| Note | Will lock the returned network entry for read access, caller must unlock when finished. | 
|---|
function TDNSClient.ResolveNetworkByAddress(AAddress:Pointer; ALength,AFamily:Integer):TNetworkEntry;
Description: To be documented
| Note |  Address will be in network order where applicable
 Will lock the returned network entry for read access, caller must unlock when finished.  | 
|---|
function TDNSClient.InAddrToName(const AAddress:TInAddr):String;
Description: Converts an Address to a Name in IN-ADDR.ARPA format
| Note | Expects Address to be in Host order | 
|---|
function TDNSClient.NameToInAddr(const AName:String):TInAddr;
Description: Converts a Name in IN-ADDR.ARPA format to an Address
| Note | Returns Address in Host order | 
|---|
function TDNSClient.In6AddrToName(const AAddress:TIn6Addr):String;
Description: Converts an Address to a Name in IP6.ARPA format
| Note | None documented | 
|---|
function TDNSClient.NameToIn6Addr(const AName:String):TIn6Addr;
Description: Converts a Name in IN-IP6.ARPA format to an Address
| Note | None documented | 
|---|
function TDNSClient.GetDNSMessageSize(AMessage:PDNSMessage):Integer;
Description: Return size of DNS Header plus Questions and Resource Records
| Note | None documented | 
|---|
function TDNSClient.GetDNSNameSize(AMessage:PDNSMessage; AOffset:Word):Word;
Description: Returns the actual size of the Name pointed to by Offset
| Note | Compressed Names will return the compressed size not the full size | 
|---|
function TDNSClient.GetDNSQuestionSize(AMessage:PDNSMessage; AOffset:Word):Word;
Description: Returns the actual size of the Question pointed to by Offset
| Note | Compressed Names will return the compressed size not the full size | 
|---|
function TDNSClient.GetDNSResourceSize(AMessage:PDNSMessage; AOffset:Word):Word;
Description: Returns the actual size of the Resource pointed to by Offset
| Note | Compressed Names will return the compressed size not the full size | 
|---|
function TDNSClient.GetDNSQuestionOffset(AMessage:PDNSMessage; ACount:Word):Word;
Description: Return the offset to the DNS Question number Count
| Note | Question numbers start at 1, if Count is higher than the current number of questions returns the offset for next Question. | 
|---|
function TDNSClient.GetDNSAnswerOffset(AMessage:PDNSMessage; ACount:Word):Word;
Description: Return the offset to the DNS Answer number Count
| Note | Answer numbers start at 1, if Count is higher than the current number of answers returns the offset for next Answer | 
|---|
function TDNSClient.GetDNSAuthorityOffset(AMessage:PDNSMessage; ACount:Word):Word;
Description: Return the offset to the DNS Authority number Count
| Note | Authority numbers start at 1, if Count is higher than the current number of authoritys returns the offset for next Authority. | 
|---|
function TDNSClient.GetDNSAdditionalOffset(AMessage:PDNSMessage; ACount:Word):Word;
Description: Return the offset to the DNS Additional number Count
| Note | Additional numbers start at 1, if Count is higher than the current number of additionals returns the offset for next Additional. | 
|---|
function TDNSClient.CreateDNSQuery(AMessage:PDNSMessage; AIdentifier:Word):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.CheckDNSResponse(AMessage:PDNSMessage; AIdentifier:Word):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.HandleDNSResponse(AMessage:PDNSMessage; AFamily,AIdentifier:Word):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.PerformDNSRequest(AData:Pointer; ALength,AFamily,AType,AClass:Word):Boolean;
Description: To be documented
| Note | Caller must confirm that the data and length are valid | 
|---|
function TDNSClient.SendDNSQuery(ASocket:TProtocolSocket; AServer:PSockAddr; AServerLength:Integer; AData:Pointer; ALength,AFamily,AType,AClass,AIdentifier:Word):Boolean;
Description: To be documented
| Note | Caller must hold the Socket lock | 
|---|
function TDNSClient.RecvDNSResponse(ASocket:TProtocolSocket; AFamily,AType,AClass,AIdentifier:Word):Boolean;
Description: To be documented
| Note | Caller must hold the Socket lock | 
|---|
function TDNSClient.InsertDNSName(AMessage:PDNSMessage; AOffset:Word; AName:Pointer; ALength:Word):Boolean;
Description: Inserts the Name into the Message
| Length | Length contains the length of the Name | 
|---|---|
| Note | Converts name into DNS encoded format from ASCII string | 
function TDNSClient.ExtractDNSName(AMessage:PDNSMessage; AOffset:Word; AName:Pointer; var ALength:Word):Boolean;
Description: Extracts the Name from the Message
| Length | Length returns the length of the Name | 
|---|---|
| Note | Converts name into ASCII string from DNS encoded format | 
function TDNSClient.ExtractDNSRData(AMessage:PDNSMessage; AOffset:Word; AData:Pointer; var ALength:Word; AType,AClass:Word):Boolean;
Description: Extracts the Resource Data from the Message
| Length | Length returns the length of the Data | 
|---|---|
| Type | For Types that are a Name simply calls ExtractDNSName to unformat the Data | 
function TDNSClient.InsertDNSQuestion(AMessage:PDNSMessage; ACount:Word; AData:Pointer; ALength,AFamily,AType,AClass:Word):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.ExtractDNSAnswer(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength:Word; AFamily:Word; var AType,AClass:Word; var ATtl:LongWord):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.ExtractDNSAuthority(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength:Word; AFamily:Word; var AType,AClass:Word; var ATtl:LongWord):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.ExtractDNSAdditional(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength:Word; AFamily:Word; var AType,AClass:Word; var ATtl:LongWord):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.GetHostByAddr(AAddr:Pointer; ALength,AFamily:Integer):PHostEnt;
Description: Performs a DNS_TYPE_PTR Query for the Domain name of the Address supplied
| Note | Address will be in network order where applicable | 
|---|
function TDNSClient.GetHostByName(AName:PChar; AFamily:Integer):PHostEnt;
Description: Performs a DNS_TYPE_A or DNS_TYPE_AAAA Query for the Address of the Domain name supplied
| Name |  If Name is blank then get the addresses for the local machine
 If Name is 'localhost' then get the loopback addresses for the local machine  | 
|---|
function TDNSClient.GetHostName(AName:PChar; ALength:Integer):Integer;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.GetServByPort(APort:Integer; AProto:PChar):PServEnt;
Description: To be documented
| Note | Port will be in network order | 
|---|
function TDNSClient.GetServByName(AName,AProto:PChar):PServEnt;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.GetProtoByNumber(AProto:Integer):PProtoEnt;
Description: To be documented
| Proto | Protocol will be in host order | 
|---|
function TDNSClient.GetProtoByName(AName:PChar):PProtoEnt;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.GetNetByAddr(AAddr:Pointer; ALength,AFamily:Integer):PNetEnt;
Description: To be documented
| Address | Address will be in network order where applicable | 
|---|
function TDNSClient.GetNetByName(AName:PChar; AFamily:Integer):PNetEnt;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.GetAddrInfo(ANodeName,AServName:PChar; AHints:PAddrInfo; var AAddrInfo:PAddrInfo):Integer;
Description: RFC 3493 protocol-independent translation from a host name to an address
| Note | None documented | 
|---|
function TDNSClient.GetNameInfo(AAddr:PSockAddr; AAddrLength:Integer; AHost:PChar; AHostLength:Integer; AServ:PChar; AServLength:Integer; AFlags:LongWord):Integer;
Description: RFC 3493 protocol-independent name resolution from an address to a host name and a port number to a service name}
| Note | None documented | 
|---|
function TDNSClient.FreeAddrInfo(AAddrInfo:PAddrInfo);
Description: Free address information that GetAddrInfo dynamically allocates in TAddrInfo structures
| Note | None documented | 
|---|
function TDNSClient.StartClient:Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.StopClient:Boolean;
Description: To be documented
| Note | None documented | 
|---|
Return to Unit Reference