TDNSClient
From Ultibo.org
								Revision as of 05:50, 2 May 2018 by Ultibo (Talk | contribs) (Created page with "Return to Unit DNS   __TOC__  === Description === ----  ''To be documented''  === Class definitions === ----   <div class="toccolours mw-collapsible mw-collapsed"...")
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 AddressEntryToHostEnt(AddressEntry:TIPAddressEntry; const AName:String; ACount:Integer):PHostEnt;
 | 
|
 function HostEntryToHostEnt(HostEntry:TIPHostEntry):PHostEnt;
 | 
|
 function NetworkEntryToNetEnt(NetworkEntry:TIPNetworkEntry):PNetEnt;
 | 
|
 function ServEntryToServEnt(ServEntry:TIPServEntry):PServEnt;
 | 
|
 function ProtoEntryToProtoEnt(ProtoEntry:TIPProtoEntry):PProtoEnt;
 | 
|
 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; AIdentifier:Word):Boolean;
 | 
|
 function SendDNSQuery(ASocket:TProtocolSocket; const AServer:TInAddr; AData:Pointer; ALength,AType,AClass,AIdentifier:Word):Boolean;
 | 
|
 function RecvDNSResponse(ASocket:TProtocolSocket; 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,AType,AClass:Word):Boolean;
 | 
|
 function ExtractDNSAnswer(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength,AType,AClass:Word; var ATtl:LongWord):Boolean;
 | 
|
 function ExtractDNSAuthority(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength,AType,AClass:Word; var ATtl:LongWord):Boolean;
 | 
|
 function ExtractDNSAdditional(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength,AType,AClass:Word; var ATtl:LongWord):Boolean;
 | 
|
public 
 | |
 function GetHostByAddr(AAddr:Pointer; ALength,AFamily:Integer):PHostEnt;
 | 
|
 function GetHostByName(AName:PChar):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,AStruct:Integer):PNetEnt;
 | 
|
 function GetNetByName(AName:PChar):PNetEnt;
 | 
|
 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.AddressEntryToHostEnt(AddressEntry:TIPAddressEntry; const AName:String; ACount:Integer):PHostEnt;
Description: To be documented
| Note | Caller must hold Address entry lock | 
|---|
function TDNSClient.HostEntryToHostEnt(HostEntry:TIPHostEntry):PHostEnt;
Description: To be documented
| Note | Caller must hold Host entry lock | 
|---|
function TDNSClient.NetworkEntryToNetEnt(NetworkEntry:TIPNetworkEntry):PNetEnt;
Description: To be documented
| Note | Caller must hold Network entry lock | 
|---|
function TDNSClient.ServEntryToServEnt(ServEntry:TIPServEntry):PServEnt;
Description: To be documented
| Note | Caller must hold Serv entry lock | 
|---|
function TDNSClient.ProtoEntryToProtoEnt(ProtoEntry:TIPProtoEntry):PProtoEnt;
Description: To be documented
| Note | Caller must hold Proto entry lock | 
|---|
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; AIdentifier:Word):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.SendDNSQuery(ASocket:TProtocolSocket; const AServer:TInAddr; AData:Pointer; ALength,AType,AClass,AIdentifier:Word):Boolean;
Description: To be documented
| Note | Caller must hold the Socket lock | 
|---|
function TDNSClient.RecvDNSResponse(ASocket:TProtocolSocket; 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,AType,AClass:Word):Boolean;
Description: To be documented
| Note | None documented | 
|---|
function TDNSClient.ExtractDNSAnswer(AMessage:PDNSMessage; ACount:Word; AName,AData:Pointer; var ANameLength,ADataLength,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,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,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):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,AStruct:Integer):PNetEnt;
Description: To be documented
| Address | Address will be in network order where applicable | 
|---|
function TDNSClient.GetNetByName(AName:PChar):PNetEnt;
Description: To be documented
| 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