' PBXB64 DNS API declarations for dnsapi.dll/windns.h.
#IF NOT %DEF(PBX_DNSAPI_PBI)
#DEFINE PBX_DNSAPI_PBI
#include once "win_types.inc"
#include once "win_consts.inc"

CONST DNS_TYPE_A = &H0001
CONST DNS_TYPE_NS = &H0002
CONST DNS_TYPE_CNAME = &H0005
CONST DNS_TYPE_SOA = &H0006
CONST DNS_TYPE_PTR = &H000C
CONST DNS_TYPE_MX = &H000F
CONST DNS_TYPE_TXT = &H0010
CONST DNS_TYPE_AAAA = &H001C
CONST DNS_TYPE_SRV = &H0021
CONST DNS_TYPE_OPT = &H0029
CONST DNS_TYPE_DS = &H002B
CONST DNS_TYPE_RRSIG = &H002E
CONST DNS_TYPE_NSEC = &H002F
CONST DNS_TYPE_DNSKEY = &H0030
CONST DNS_TYPE_TLSA = &H0034
CONST DNS_TYPE_HTTPS = &H0041
CONST DNS_TYPE_SVCB = &H0040
CONST DNS_QUERY_STANDARD = &H00000000
CONST DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE = &H00000001
CONST DNS_QUERY_USE_TCP_ONLY = &H00000002
CONST DNS_QUERY_NO_RECURSION = &H00000004
CONST DNS_QUERY_BYPASS_CACHE = &H00000008
CONST DNS_QUERY_NO_WIRE_QUERY = &H00000010
CONST DNS_QUERY_NO_LOCAL_NAME = &H00000020
CONST DNS_QUERY_NO_HOSTS_FILE = &H00000040
CONST DNS_QUERY_NO_NETBT = &H00000080
CONST DNS_QUERY_WIRE_ONLY = &H00000100
CONST DNS_QUERY_TREAT_AS_FQDN = &H00001000
CONST DNS_QUERY_DONT_RESET_TTL_VALUES = &H00100000
CONST DNS_QUERY_DISABLE_IDN_ENCODING = &H00200000
CONST DNS_FREE_FLAT = 0
CONST DNS_FREE_RECORD_LIST = 1
CONST DNS_FREE_PARSED_MESSAGE_FIELDS = 2
CONST DNS_NAME_DOMAIN = 0
CONST DNS_NAME_DOMAIN_LABEL = 1
CONST DNS_NAME_HOST = 2
CONST DNS_NAME_HOST_LABEL = 3
CONST DNS_NAME_WILDCARD = 4
CONST DNS_NAME_SRV = 5
CONST DNS_NAME_MULTILABEL = 6

TYPE DNS_A_DATA
    IpAddress AS DWORD
END TYPE

TYPE DNS_AAAA_DATA
    Ip6Address AS PBX_BYTE16
END TYPE

TYPE DNS_PTR_DATA
    pNameHost AS QUAD
END TYPE

TYPE DNS_MX_DATA
    pNameExchange AS QUAD
    wPreference AS WORD
    Pad AS WORD
END TYPE

TYPE DNS_SRV_DATA
    pNameTarget AS QUAD
    wPriority AS WORD
    wWeight AS WORD
    wPort AS WORD
    Pad AS WORD
END TYPE

TYPE DNS_RECORD_FIXED
    pNextRecord AS QUAD
    pName AS QUAD
    wType AS WORD
    wDataLength AS WORD
    Flags AS DWORD
    dwTtl AS DWORD
    dwReserved AS DWORD
    Data AS PBX_BYTE512
END TYPE

DECLARE FUNCTION DnsQuery_A LIB "dnsapi.dll" ALIAS "DnsQuery_A" (BYVAL pszName AS ASCIIZ PTR, BYVAL wType AS WORD, BYVAL Options AS DWORD, BYVAL pExtra AS QUAD, BYVAL ppQueryResults AS QUAD, BYVAL pReserved AS QUAD) AS LONG
DECLARE FUNCTION DnsQuery_W LIB "dnsapi.dll" ALIAS "DnsQuery_W" (BYVAL pszName AS WSTRING, BYVAL wType AS WORD, BYVAL Options AS DWORD, BYVAL pExtra AS QUAD, BYVAL ppQueryResults AS QUAD, BYVAL pReserved AS QUAD) AS LONG
DECLARE SUB DnsRecordListFree LIB "dnsapi.dll" ALIAS "DnsRecordListFree" (BYVAL pRecordList AS QUAD, BYVAL FreeType AS LONG)
DECLARE SUB DnsFree LIB "dnsapi.dll" ALIAS "DnsFree" (BYVAL pData AS QUAD, BYVAL FreeType AS LONG)
DECLARE FUNCTION DnsValidateName_A LIB "dnsapi.dll" ALIAS "DnsValidateName_A" (BYVAL pszName AS ASCIIZ PTR, BYVAL Format AS LONG) AS LONG
DECLARE FUNCTION DnsValidateName_W LIB "dnsapi.dll" ALIAS "DnsValidateName_W" (BYVAL pszName AS WSTRING, BYVAL Format AS LONG) AS LONG
DECLARE FUNCTION DnsFlushResolverCache LIB "dnsapi.dll" ALIAS "DnsFlushResolverCache" () AS LONG
DECLARE FUNCTION DnsModifyRecordsInSet_A LIB "dnsapi.dll" ALIAS "DnsModifyRecordsInSet_A" (BYVAL pAddRecords AS QUAD, BYVAL pDeleteRecords AS QUAD, BYVAL Options AS DWORD, BYVAL hCredentials AS QUAD, BYVAL pExtraList AS QUAD, BYVAL pReserved AS QUAD) AS LONG
DECLARE FUNCTION DnsModifyRecordsInSet_W LIB "dnsapi.dll" ALIAS "DnsModifyRecordsInSet_W" (BYVAL pAddRecords AS QUAD, BYVAL pDeleteRecords AS QUAD, BYVAL Options AS DWORD, BYVAL hCredentials AS QUAD, BYVAL pExtraList AS QUAD, BYVAL pReserved AS QUAD) AS LONG

#ENDIF
