Difference between revisions of "Unit DNS"
| (One intermediate revision by the same user not shown) | |||
| Line 105: | Line 105: | ||
|-  | |-  | ||
| <code>DNS_OPCODE_UNKNOWN = 3;</code>  | | <code>DNS_OPCODE_UNKNOWN = 3;</code>  | ||
| − | |    | + | |    | 
|-  | |-  | ||
| <code>DNS_OPCODE_NOTIFY = 4;</code>  | | <code>DNS_OPCODE_NOTIFY = 4;</code>  | ||
| Line 508: | Line 508: | ||
|-  | |-  | ||
|}  | |}  | ||
| − | </div></div>   | + | </div></div>  | 
| + | |||
| + | '''DNS client name'''  | ||
| + | |||
| + | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">  | ||
| + | <code>PDNSClientName = ^TDNSClientName;</code>  | ||
| + | |||
| + | <code>TDNSClientName = array[0..MAX_NAME_SIZE - 1] of Char;</code>  | ||
| + | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">  | ||
| + | {| class="wikitable" style="font-size: 14px; background: white;"  | ||
| + | |-  | ||
| + | |    | ||
| + | | style="width: 50%;"|   | ||
| + | |-  | ||
| + | |}  | ||
| + | </div></div>     | ||
'''DNS client data'''  | '''DNS client data'''  | ||
| Line 526: | Line 541: | ||
| style="width: 50%;"|   | | style="width: 50%;"|   | ||
|-  | |-  | ||
| − | | <code>HostEntName:  | + | | <code>HostEntName:TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| − | | <code>HostAliasesPtr:PChar;</code>  | + | | <code>HostAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;</code>  | 
| − | |   | + | | One extra for terminating null pointer  | 
|-  | |-  | ||
| − | | <code>HostAliases:array[0..  | + | | <code>HostAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| − | | <code>HostAddrListPtr:PChar;</code>  | + | | <code>HostAddrListPtr:array[0..MAX_HOST_ALIASES] of PChar;</code>  | 
| − | |   | + | | One extra for terminating null pointer  | 
|-  | |-  | ||
| <code>HostAddrList:array[0..MAX_HOST_ALIASES - 1] of TInAddr;</code>  | | <code>HostAddrList:array[0..MAX_HOST_ALIASES - 1] of TInAddr;</code>  | ||
| + | |    | ||
| + | |-  | ||
| + | | <code>HostAddr6ListPtr:array[0..MAX_HOST_ALIASES] of PChar;</code>  | ||
| + | | One extra for terminating null pointer  | ||
| + | |-  | ||
| + | | <code>HostAddr6List:array[0..MAX_HOST_ALIASES - 1] of TIn6Addr;</code>  | ||
|    | |    | ||
|-  | |-  | ||
| Line 546: | Line 567: | ||
|    | |    | ||
|-  | |-  | ||
| − | | <code>NetEntName:  | + | | <code>NetEntName:TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| − | | <code>NetAliasesPtr:PChar;</code>  | + | | <code>NetAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;</code>  | 
| − | |   | + | | One extra for terminating null pointer  | 
|-  | |-  | ||
| − | | <code>NetAliases:array[0..  | + | | <code>NetAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| Line 560: | Line 581: | ||
|    | |    | ||
|-  | |-  | ||
| − | | <code>ServEntName:  | + | | <code>ServEntName:TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| − | | <code>ServAliasesPtr:PChar;</code>  | + | | <code>ServAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;</code>  | 
| − | |   | + | | One extra for terminating null pointer  | 
|-  | |-  | ||
| − | | <code>ServAliases:array[0..  | + | | <code>ServAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| − | | <code>ServEntProto:  | + | | <code>ServEntProto:TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| Line 577: | Line 598: | ||
|    | |    | ||
|-  | |-  | ||
| − | | <code>ProtoEntName:  | + | | <code>ProtoEntName:TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
| − | | <code>ProtoAliasesPtr:PChar;</code>  | + | | <code>ProtoAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;</code>  | 
| − | |   | + | | One extra for terminating null pointer  | 
|-  | |-  | ||
| − | | <code>ProtoAliases:array[0..  | + | | <code>ProtoAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;</code>  | 
|    | |    | ||
|-  | |-  | ||
Latest revision as of 02:24, 6 March 2025
Return to Unit Reference
Contents
Description
Ultibo DNS Client unit
Note: DNS Client is IPv4 based, for IPv6 see new Winsock2 functions
See RFC 1035 Section 4 for details
Constants
 DNS_*  DNS_TIMEOUT = 2000;
 | 
We wait for 2 seconds for a DNS reply | 
 DNS_RETRIES = 2;
 | 
Try the request 2 times | 
 DNS_HEADER_SIZE = 12;
 | 
SizeOf(TDNSHeader); | 
 DNS_QUESTION_SIZE = 4;
 | 
SizeOf(TDNSQuestion); | 
 DNS_RESOURCE_SIZE = 10;
 | 
SizeOf(TDNSResource); Not including Record Data | 
 MAX_DNS_NAME = 255;
 | 
|
 MAX_DNS_LABEL = 63;
 | 
|
 MAX_DNS_MESSAGE = 512;
 | 
Maximum Size of DNS Message | 
 
 DNS_FLAG_*  DNS_FLAG_RESPONSE = $8000;
 | 
query = 0, response = 1 | 
 DNS_FLAG_AUTHORITY = $0400;
 | 
Authoritative answer | 
 DNS_FLAG_TRUNCATED = $0200;
 | 
Truncation, response was cut off at 512 | 
 DNS_FLAG_DO_RECURSE = $0100;
 | 
Recursion desired | 
 DNS_FLAG_CAN_RECURSE = $0080;
 | 
Recursion available | 
 
 DNS_*_MASK  DNS_OPCODE_MASK = $7800;
 | 
Opcode | 
 DNS_RESPONSE_MASK = $000F;
 | 
Response code | 
 
 DNS_OPCODE_*  DNS_OPCODE_QUERY = 0;
 | 
A standard query | 
 DNS_OPCODE_IQUERY = 1;
 | 
An inverse query | 
 DNS_OPCODE_SERVER_STATUS = 2;
 | 
|
 DNS_OPCODE_UNKNOWN = 3;
 | 
|
 DNS_OPCODE_NOTIFY = 4;
 | 
|
 DNS_OPCODE_UPDATE = 5;
 | 
 
 DNS_RESPONSE_*  DNS_RESPONSE_NO_ERROR = 0;
 | 
|
 DNS_RESPONSE_FORMAT_ERROR = 1;
 | 
|
 DNS_RESPONSE_SERVER_FAILURE = 2;
 | 
|
 DNS_RESPONSE_NAME_ERROR = 3;
 | 
|
 DNS_RESPONSE_NOT_IMPLEMENTED = 4;
 | 
|
 DNS_RESPONSE_REFUSED = 5;
 | 
 
 DNS_TYPE_*  DNS_TYPE_A = $0001;
 | 
Host address resource record (RR) | 
 DNS_TYPE_NS = $0002;
 | 
|
 DNS_TYPE_MD = $0003;
 | 
|
 DNS_TYPE_MF = $0004;
 | 
|
 DNS_TYPE_CNAME = $0005;
 | 
|
 DNS_TYPE_SOA = $0006;
 | 
|
 DNS_TYPE_MB = $0007;
 | 
|
 DNS_TYPE_MG = $0008;
 | 
|
 DNS_TYPE_MR = $0009;
 | 
|
 DNS_TYPE_NULL = $000a;
 | 
|
 DNS_TYPE_WKS = $000b;
 | 
|
 DNS_TYPE_PTR = $000c;
 | 
A domain name ptr | 
 DNS_TYPE_HINFO = $000d;
 | 
|
 DNS_TYPE_MINFO = $000e;
 | 
|
 DNS_TYPE_MX = $000f;
 | 
Mail exchange | 
 DNS_TYPE_TEXT = $0010;
 | 
|
 DNS_TYPE_RP = $0011;
 | 
|
 DNS_TYPE_AFSDB = $0012;
 | 
|
 DNS_TYPE_X25 = $0013;
 | 
|
 DNS_TYPE_ISDN = $0014;
 | 
|
 DNS_TYPE_RT = $0015;
 | 
|
 DNS_TYPE_NSAP = $0016;
 | 
|
 DNS_TYPE_NSAPPTR = $0017;
 | 
|
 DNS_TYPE_SIG = $0018;
 | 
|
 DNS_TYPE_KEY = $0019;
 | 
|
 DNS_TYPE_PX = $001a;
 | 
|
 DNS_TYPE_GPOS = $001b;
 | 
|
 DNS_TYPE_AAAA = $001c;
 | 
|
 DNS_TYPE_LOC = $001d;
 | 
|
 DNS_TYPE_NXT = $001e;
 | 
|
 DNS_TYPE_EID = $001f;
 | 
|
 DNS_TYPE_NIMLOC = $0020;
 | 
|
 DNS_TYPE_SRV = $0021;
 | 
|
 DNS_TYPE_ATMA = $0022;
 | 
|
 DNS_TYPE_NAPTR = $0023;
 | 
|
 DNS_TYPE_KX = $0024;
 | 
|
 DNS_TYPE_CERT = $0025;
 | 
|
 DNS_TYPE_A6 = $0026;
 | 
|
 DNS_TYPE_DNAME = $0027;
 | 
|
 DNS_TYPE_SINK = $0028;
 | 
|
 DNS_TYPE_OPT = $0029;
 | 
|
 DNS_TYPE_DS = $002B;
 | 
|
 DNS_TYPE_RRSIG = $002E;
 | 
|
 DNS_TYPE_NSEC = $002F;
 | 
|
 DNS_TYPE_DNSKEY = $0030;
 | 
|
 DNS_TYPE_DHCID = $0031;
 | 
|
 DNS_TYPE_UINFO = $0064;
 | 
|
 DNS_TYPE_UID = $0065;
 | 
|
 DNS_TYPE_GID = $0066;
 | 
|
 DNS_TYPE_UNSPEC = $0067;
 | 
|
 DNS_TYPE_ADDRS = $00f8;
 | 
|
 DNS_TYPE_TKEY = $00f9;
 | 
|
 DNS_TYPE_TSIG = $00fa;
 | 
|
 DNS_TYPE_IXFR = $00fb;
 | 
|
 DNS_TYPE_AXFR = $00fc;
 | 
|
 DNS_TYPE_MAILB = $00fd;
 | 
|
 DNS_TYPE_MAILA = $00fe;
 | 
|
 DNS_TYPE_ALL = $00ff;
 | 
|
 DNS_TYPE_ANY = $00ff;
 | 
|
 DNS_TYPE_WINS = $ff01;
 | 
|
 DNS_TYPE_WINSR = $ff02;
 | 
|
 DNS_TYPE_NBSTAT = DNS_TYPE_WINSR;
 | 
 DNS_CLASS_*  DNS_CLASS_INTERNET = $0001;
 | 
|
 DNS_CLASS_CSNET = $0002;
 | 
|
 DNS_CLASS_CHAOS = $0003;
 | 
|
 DNS_CLASS_HESIOD = $0004;
 | 
|
 DNS_CLASS_NONE = $00fe;
 | 
|
 DNS_CLASS_ALL = $00ff;
 | 
|
 DNS_CLASS_ANY = $00ff;
 | 
|
 DNS_CLASS_IN = DNS_CLASS_INTERNET;
 | 
ARPA internet class | 
 DNS_CLASS_CS = DNS_CLASS_CSNET;
 | 
|
 DNS_CLASS_WILD = DNS_CLASS_ANY;
 | 
Wildcard for several of the classifications | 
  
 DNS_POINTER_*  DNS_POINTER_MASK = $C0;
 | 
Mask to indicate pointer to previously used name | 
Type definitions
DNS specific types
PDNSHeader = ^TDNSHeader;
TDNSHeader = packed record
| Note: All Network Order | |
 Identifier:Word;
 | 
unique identifier | 
 Flags:Word;
 | 
QD/Opcode/AA/TC/RD/RA/RCODE | 
 QuestionCount:Word;
 | 
question section, number of entries | 
 AnswerCount:Word;
 | 
answers, how many | 
 AuthorityCount:Word;
 | 
count of name server RRs | 
 AdditionalCount:Word;
 | 
number of "additional" records | 
DNS message
PDNSMessage = ^TDNSMessage;
TDNSMessage = packed record
 DNS:TDNSHeader;
 | 
|
 Data:array[0..(MAX_DNS_MESSAGE - DNS_HEADER_SIZE) - 1] of Byte;
 | 
DNS name
PDNSName = ^TDNSName;
TDNSName = array[0..MAX_DNS_NAME - 1] of Char;
DNS question
PDNSQuestion = ^TDNSQuestion;
TDNSQuestion = packed record
| Note: All Network Order | |
 Name:TDNSName;
 | 
variable length question name | 
 QuestionType:Word;
 | 
question type (eg DNS_TYPE_A) | 
 QuestionClass:Word;
 | 
question class (eg DNS_CLASS_IN) | 
DNS resource
PDNSResource = ^TDNSResource;
TDNSResource = packed record
| Note: All Network Order | |
 Name:TDNSName;
 | 
variable length resource name | 
 RecordType:Word;
 | 
resource record type (eg DNS_TYPE_A) | 
 RecordClass:Word;
 | 
resource record class (eg DNS_CLASS_IN) | 
 Ttl:LongWord;
 | 
time-to-live, changed to 32 bits | 
 DataLength:Word;
 | 
length of data field | 
 RecordData:array[0..MAX_DNS_MESSAGE - 1] of Byte;
 | 
data field | 
DNS client name
PDNSClientName = ^TDNSClientName;
TDNSClientName = array[0..MAX_NAME_SIZE - 1] of Char;
DNS client data
PDNSClientData = ^TDNSClientData;
TDNSClientData = record
| Note: Used for TLS Data | |
| Host Ent | |
 HostEnt:THostEnt;
 | 
|
 HostEntName:TDNSClientName;
 | 
|
 HostAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;
 | 
One extra for terminating null pointer | 
 HostAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;
 | 
|
 HostAddrListPtr:array[0..MAX_HOST_ALIASES] of PChar;
 | 
One extra for terminating null pointer | 
 HostAddrList:array[0..MAX_HOST_ALIASES - 1] of TInAddr;
 | 
|
 HostAddr6ListPtr:array[0..MAX_HOST_ALIASES] of PChar;
 | 
One extra for terminating null pointer | 
 HostAddr6List:array[0..MAX_HOST_ALIASES - 1] of TIn6Addr;
 | 
|
| Net Ent | |
 NetEnt:TNetEnt;
 | 
|
 NetEntName:TDNSClientName;
 | 
|
 NetAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;
 | 
One extra for terminating null pointer | 
 NetAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;
 | 
|
| Serv Ent | |
 ServEnt:TServEnt;
 | 
|
 ServEntName:TDNSClientName;
 | 
|
 ServAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;
 | 
One extra for terminating null pointer | 
 ServAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;
 | 
|
 ServEntProto:TDNSClientName;
 | 
|
| Proto Ent | |
 ProtoEnt:TProtoEnt;
 | 
|
 ProtoEntName:TDNSClientName;
 | 
|
 ProtoAliasesPtr:array[0..MAX_NAME_ALIASES] of PChar;
 | 
One extra for terminating null pointer | 
 ProtoAliases:array[0..MAX_NAME_ALIASES - 1] of TDNSClientName;
 | 
|
Class definitions
DNS specific classes
 TDNSClient = class(TNetworkClient)
 | 
Public variables
None defined
Function declarations
Initialization functions
procedure DNSInit;
| Note | None documented | 
|---|
function DNSStart:LongWord;
| Note | None documented | 
|---|
function DNSStop:LongWord;
| Note | None documented | 
|---|
Return to Unit Reference