Difference between revisions of "Unit DNS"
From Ultibo.org
Line 77: | Line 77: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DNS field mask''' <code> | + | <div style="font-size: 14px; padding-left: 12px;">'''DNS field mask''' <code> DNS_*_MASK </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" |
Revision as of 02:19, 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 specific 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_*
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 field mask
DNS_*_MASK
DNS_OPCODE_MASK = $7800;
|
Opcode |
DNS_RESPONSE_MASK = $000F;
|
Response code |
DNS opcode
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 code
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 record type
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 address class
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 message compression
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 data
PDNSClientData = ^TDNSClientData;
TDNSClientData = record
Note: Used for TLS Data | |
Host Ent | |
HostEnt:THostEnt;
|
|
HostEntName:array[0..MAX_NAME_SIZE - 1] of Char;
|
|
HostAliasesPtr:PChar;
|
|
HostAliases:array[0..(MAX_NAME_SIZE * MAX_NAME_ALIASES) - 1] of Char;
|
|
HostAddrListPtr:PChar;
|
|
HostAddrList:array[0..MAX_HOST_ALIASES - 1] of TInAddr;
|
|
Net Ent | |
NetEnt:TNetEnt;
|
|
NetEntName:array[0..MAX_NAME_SIZE - 1] of Char;
|
|
NetAliasesPtr:PChar;
|
|
NetAliases:array[0..(MAX_NAME_SIZE * MAX_NAME_ALIASES) - 1] of Char;
|
|
Serv Ent | |
ServEnt:TServEnt;
|
|
ServEntName:array[0..MAX_NAME_SIZE - 1] of Char;
|
|
ServAliasesPtr:PChar;
|
|
ServAliases:array[0..(MAX_NAME_SIZE * MAX_NAME_ALIASES) - 1] of Char;
|
|
ServEntProto:array[0..MAX_NAME_SIZE - 1] of Char;
|
|
Proto Ent | |
ProtoEnt:TProtoEnt;
|
|
ProtoEntName:array[0..MAX_NAME_SIZE - 1] of Char;
|
|
ProtoAliasesPtr:PChar;
|
|
ProtoAliases:array[0..(MAX_NAME_SIZE * MAX_NAME_ALIASES) - 1] of Char;
|
Class definitions
DNS specific classes
TDNSClient = class(TNetworkClient)
|
Public variables
None defined
Function declarations
Initialization functions
procedure DNSInit;
Description: To be documented
Note | None documented |
---|
function DNSStart:LongWord;
Description: To be documented
Note | None documented |
---|
function DNSStop:LongWord;
Description: To be documented
Note | None documented |
---|
Return to Unit Reference