ReactOS 0.4.15-dev-8119-g4fb2fdb
windns_undoc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DNS_CACHE_ENTRY
 

Typedefs

typedef struct _DNS_CACHE_ENTRY DNS_CACHE_ENTRY
 
typedef struct _DNS_CACHE_ENTRYPDNS_CACHE_ENTRY
 

Functions

BOOL WINAPI DnsFlushResolverCache (VOID)
 
BOOL WINAPI DnsGetCacheDataTable (_Out_ PDNS_CACHE_ENTRY *DnsCache)
 
DWORD WINAPI GetCurrentTimeInSeconds (VOID)
 
DNS_STATUS WINAPI Query_Main (LPCWSTR Name, WORD Type, DWORD Options, PDNS_RECORD *QueryResultSet)
 

Typedef Documentation

◆ DNS_CACHE_ENTRY

◆ PDNS_CACHE_ENTRY

Function Documentation

◆ DnsFlushResolverCache()

BOOL WINAPI DnsFlushResolverCache ( VOID  )

Definition at line 933 of file query.c.

934{
935 DNS_STATUS Status = ERROR_SUCCESS;
936
937 DPRINT("DnsFlushResolverCache()\n");
938
940 {
942 DPRINT("R_ResolverFlushCache() returned %lu\n", Status);
943 }
945 {
947 DPRINT("Exception returned %lu\n", Status);
948 }
950
951 return (Status == ERROR_SUCCESS);
952}
DWORD __stdcall R_ResolverFlushCache(_In_ DNSRSLVR_HANDLE pszServerName)
Definition: rpcserver.c:62
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcEndExcept
Definition: rpc.h:128
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExcept(expr)
Definition: rpc.h:127
#define RpcExceptionCode()
Definition: rpc.h:132
#define DPRINT
Definition: sndvol32.h:73

Referenced by FlushDns().

◆ DnsGetCacheDataTable()

BOOL WINAPI DnsGetCacheDataTable ( _Out_ PDNS_CACHE_ENTRY DnsCache)

Definition at line 1055 of file query.c.

1057{
1058 DNS_STATUS Status = ERROR_SUCCESS;
1059 PDNS_CACHE_ENTRY CacheEntries = NULL;
1060
1061 if (DnsCache == NULL)
1062 return FALSE;
1063
1065 {
1067 &CacheEntries);
1068 DPRINT("CRrReadCache() returned %lu\n", Status);
1069 }
1071 {
1073 DPRINT1("Exception returned %lu\n", Status);
1074 }
1076
1077 if (Status != ERROR_SUCCESS)
1078 return FALSE;
1079
1080 if (CacheEntries == NULL)
1081 return FALSE;
1082
1083 *DnsCache = CacheEntries;
1084
1085 return TRUE;
1086}
#define DPRINT1
Definition: precomp.h:8
static RESOLVER_CACHE DnsCache
Definition: cache.c:14
DWORD __stdcall CRrReadCache(_In_ DNSRSLVR_HANDLE pwszServerName, _Out_ DNS_CACHE_ENTRY **ppCacheEntries)
Definition: rpcserver.c:48
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Definition: windns_undoc.h:9

Referenced by DisplayDns().

◆ GetCurrentTimeInSeconds()

DWORD WINAPI GetCurrentTimeInSeconds ( VOID  )

Definition at line 1090 of file query.c.

1091{
1092 FILETIME Time;
1094 ULARGE_INTEGER lTime, lAdj;
1095 SYSTEMTIME st = {1970, 1, 0, 1, 0, 0, 0};
1096
1098 memcpy(&lAdj, &Adjustment, sizeof(lAdj));
1100 memcpy(&lTime, &Time, sizeof(lTime));
1101 lTime.QuadPart -= lAdj.QuadPart;
1102 return (DWORD)(lTime.QuadPart/10000000ULL);
1103}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PLARGE_INTEGER Time
Definition: time.c:105
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
_In_ KPRIORITY _In_ LONG Adjustment
Definition: kefuncs.h:427

Referenced by WSPAccept(), WSPConnect(), and WSPGetSockOpt().

◆ Query_Main()

DNS_STATUS WINAPI Query_Main ( LPCWSTR  Name,
WORD  Type,
DWORD  Options,
PDNS_RECORD QueryResultSet 
)

Definition at line 654 of file query.c.

658{
659 adns_state astate;
660 int quflags = (Options & DNS_QUERY_NO_RECURSION) == 0 ? adns_qf_search : 0;
661 int adns_error;
662 adns_answer *answer;
663 LPSTR CurrentName;
664 unsigned CNameLoop;
665 PFIXED_INFO network_info;
666 ULONG network_info_blen = 0;
667 DWORD network_info_result;
668 PIP_ADDR_STRING pip;
670 struct in_addr addr;
671 PCHAR HostWithDomainName;
672 PCHAR AnsiName;
673 size_t NameLen = 0;
674
675 if (Name == NULL)
677 if (QueryResultSet == NULL)
679
680 *QueryResultSet = NULL;
681
682 switch (Type)
683 {
684 case DNS_TYPE_A:
685 /* FIXME: how much instead of MAX_PATH? */
686 NameLen = WideCharToMultiByte(CP_ACP,
687 0,
688 Name,
689 -1,
690 NULL,
691 0,
692 NULL,
693 0);
694 AnsiName = RtlAllocateHeap(RtlGetProcessHeap(), 0, NameLen);
695 if (NULL == AnsiName)
696 {
697 return ERROR_OUTOFMEMORY;
698 }
700 0,
701 Name,
702 -1,
703 AnsiName,
704 NameLen,
705 NULL,
706 0);
707 NameLen--;
708
709 network_info_result = GetNetworkParams(NULL, &network_info_blen);
710 network_info = (PFIXED_INFO)RtlAllocateHeap(RtlGetProcessHeap(), 0, (size_t)network_info_blen);
711 if (NULL == network_info)
712 {
713 return ERROR_OUTOFMEMORY;
714 }
715
716 network_info_result = GetNetworkParams(network_info, &network_info_blen);
717 if (network_info_result != ERROR_SUCCESS)
718 {
719 RtlFreeHeap(RtlGetProcessHeap(), 0, network_info);
720 return network_info_result;
721 }
722
723 if ((Address = CheckForCurrentHostname(NameLen != 0 ? AnsiName : network_info->HostName, network_info)) != 0)
724 {
725 size_t TempLen = 2, StringLength = 0;
726 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
727 StringCchLengthA(network_info->HostName, sizeof(network_info->HostName), &StringLength);
728 TempLen += StringLength;
729 StringCchLengthA(network_info->DomainName, sizeof(network_info->DomainName), &StringLength);
730 TempLen += StringLength;
731 HostWithDomainName = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(), 0, TempLen);
732 StringCchCopyA(HostWithDomainName, TempLen, network_info->HostName);
733 if (network_info->DomainName[0])
734 {
735 StringCchCatA(HostWithDomainName, TempLen, ".");
736 StringCchCatA(HostWithDomainName, TempLen, network_info->DomainName);
737 }
738 RtlFreeHeap(RtlGetProcessHeap(), 0, network_info);
739 *QueryResultSet = (PDNS_RECORD)RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DNS_RECORD));
740
741 if (NULL == *QueryResultSet)
742 {
743 RtlFreeHeap(RtlGetProcessHeap(), 0, HostWithDomainName);
744 return ERROR_OUTOFMEMORY;
745 }
746
747 (*QueryResultSet)->pNext = NULL;
748 (*QueryResultSet)->wType = Type;
749 (*QueryResultSet)->wDataLength = sizeof(DNS_A_DATA);
750 (*QueryResultSet)->Flags.S.Section = DnsSectionAnswer;
751 (*QueryResultSet)->Flags.S.CharSet = DnsCharSetUnicode;
752 (*QueryResultSet)->Data.A.IpAddress = Address;
753
754 (*QueryResultSet)->pName = (LPSTR)DnsCToW(HostWithDomainName);
755
756 RtlFreeHeap(RtlGetProcessHeap(), 0, HostWithDomainName);
757 return (*QueryResultSet)->pName ? ERROR_SUCCESS : ERROR_OUTOFMEMORY;
758 }
759
760 if ((Options & DNS_QUERY_NO_WIRE_QUERY) != 0)
761 {
762 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
763 RtlFreeHeap(RtlGetProcessHeap(), 0, network_info);
765 }
766
768 if (adns_error != adns_s_ok)
769 {
770 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
771 RtlFreeHeap(RtlGetProcessHeap(), 0, network_info);
772 return DnsIntTranslateAdnsToDNS_STATUS(adns_error);
773 }
774 for (pip = &(network_info->DnsServerList); pip; pip = pip->Next)
775 {
776 addr.s_addr = inet_addr(pip->IpAddress.String);
777 if ((addr.s_addr != INADDR_ANY) && (addr.s_addr != INADDR_NONE))
778 adns_addserver(astate, addr);
779 }
780 if (network_info->DomainName[0])
781 {
782 adns_ccf_search(astate, "LOCALDOMAIN", -1, network_info->DomainName);
783 }
784 RtlFreeHeap(RtlGetProcessHeap(), 0, network_info);
785
786 if (!adns_numservers(astate))
787 {
788 /* There are no servers to query so bail out */
789 adns_finish(astate);
790 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
792 }
793
794 /*
795 * adns doesn't resolve chained CNAME records (a CNAME which points to
796 * another CNAME pointing to another... pointing to an A record), according
797 * to a mailing list thread the authors believe that chained CNAME records
798 * are invalid and the DNS entries should be fixed. That's a nice academic
799 * standpoint, but there certainly are chained CNAME records out there,
800 * even some fairly major ones (at the time of this writing
801 * download.mozilla.org is a chained CNAME). Everyone else seems to resolve
802 * these fine, so we should too. So we loop here to try to resolve CNAME
803 * chains ourselves. Of course, there must be a limit to protect against
804 * CNAME loops.
805 */
806
807#define CNAME_LOOP_MAX 16
808
809 CurrentName = AnsiName;
810
811 for (CNameLoop = 0; CNameLoop < CNAME_LOOP_MAX; CNameLoop++)
812 {
813 adns_error = adns_synchronous(astate, CurrentName, adns_r_addr, quflags, &answer);
814
815 if (adns_error != adns_s_ok)
816 {
817 adns_finish(astate);
818
819 if (CurrentName != AnsiName)
820 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentName);
821
822 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
823 return DnsIntTranslateAdnsToDNS_STATUS(adns_error);
824 }
825
826 if (answer && answer->rrs.addr)
827 {
828 if (CurrentName != AnsiName)
829 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentName);
830
831 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
832 *QueryResultSet = (PDNS_RECORD)RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DNS_RECORD));
833
834 if (NULL == *QueryResultSet)
835 {
836 adns_finish(astate);
837 return ERROR_OUTOFMEMORY;
838 }
839
840 (*QueryResultSet)->pNext = NULL;
841 (*QueryResultSet)->wType = Type;
842 (*QueryResultSet)->wDataLength = sizeof(DNS_A_DATA);
843 (*QueryResultSet)->Flags.S.Section = DnsSectionAnswer;
844 (*QueryResultSet)->Flags.S.CharSet = DnsCharSetUnicode;
845 (*QueryResultSet)->Data.A.IpAddress = answer->rrs.addr->addr.inet.sin_addr.s_addr;
846
847 adns_finish(astate);
848
849 (*QueryResultSet)->pName = (LPSTR)xstrsave(Name);
850
851 return (*QueryResultSet)->pName ? ERROR_SUCCESS : ERROR_OUTOFMEMORY;
852 }
853
854 if (NULL == answer || adns_s_prohibitedcname != answer->status || NULL == answer->cname)
855 {
856 adns_finish(astate);
857
858 if (CurrentName != AnsiName)
859 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentName);
860
861 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
863 }
864
865 if (CurrentName != AnsiName)
866 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentName);
867
868 CurrentName = (LPSTR)xstrsaveA(answer->cname);
869
870 if (!CurrentName)
871 {
872 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
873 adns_finish(astate);
874 return ERROR_OUTOFMEMORY;
875 }
876 }
877
878 adns_finish(astate);
879 RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiName);
880 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentName);
882
883 default:
884 return ERROR_OUTOFMEMORY; /* XXX arty: find a better error code. */
885 }
886}
Type
Definition: Type.h:7
DNS_STATUS DnsIntTranslateAdnsToDNS_STATUS(int Status)
Definition: adns.c:17
@ adns_r_addr
Definition: adns.h:143
ADNS_API void adns_addserver(adns_state state, struct in_addr server)
Definition: setup.c:712
ADNS_API void adns_finish(adns_state ads)
Definition: setup.c:650
ADNS_API int adns_synchronous(adns_state ads, const char *owner, adns_rrtype type, adns_queryflags flags, adns_answer **answer_r)
Definition: query.c:314
ADNS_API int adns_numservers(adns_state state)
Definition: setup.c:718
ADNS_API int adns_init(adns_state *newstate_r, adns_initflags flags, FILE *diagfile)
Definition: setup.c:568
@ adns_if_noerrprint
Definition: adns.h:89
@ adns_if_noenv
Definition: adns.h:88
@ adns_if_noserverwarn
Definition: adns.h:90
@ adns_s_ok
Definition: adns.h:216
@ adns_s_prohibitedcname
Definition: adns.h:245
ADNS_API void adns_ccf_search(adns_state state, const char *fn, int lno, const char *buf)
Definition: setup.c:715
@ adns_qf_search
Definition: adns.h:101
#define INADDR_NONE
Definition: tcp.c:42
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define CNAME_LOOP_MAX
static PWCHAR DnsCToW(const CHAR *NarrowString)
Definition: query.c:187
IP4_ADDRESS CheckForCurrentHostname(CONST CHAR *Name, PFIXED_INFO network_info)
Definition: query.c:582
CHAR * xstrsaveA(const CHAR *str)
Definition: query.c:562
WCHAR * xstrsave(const WCHAR *str)
Definition: query.c:544
__kernel_size_t size_t
Definition: linux.h:237
GLenum const GLvoid * addr
Definition: glext.h:9621
DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
struct FIXED_INFO * PFIXED_INFO
#define inet_addr(cp)
Definition: inet.h:98
#define INADDR_ANY
Definition: inet.h:53
#define PCHAR
Definition: match.c:90
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static WCHAR Address[46]
Definition: ping.c:68
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:832
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:84
char HostName[MAX_HOSTNAME_LEN+4]
Definition: iptypes.h:81
char DomainName[MAX_DOMAIN_NAME_LEN+4]
Definition: iptypes.h:82
char String[4 *4]
Definition: iptypes.h:42
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:46
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
adns_rr_addr * addr
Definition: adns.h:322
adns_status status
Definition: adns.h:311
char * cname
Definition: adns.h:312
union adns_answer::@4230 rrs
union adns_rr_addr::@4229 addr
struct sockaddr_in inet
Definition: adns.h:271
Definition: tcpip.h:126
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534
#define DNS_RECORD
Definition: windns.h:635
#define DNS_QUERY_NO_RECURSION
Definition: windns.h:11
@ DnsSectionAnswer
Definition: windns.h:154
DWORD IP4_ADDRESS
Definition: windns.h:36
@ DnsCharSetUnicode
Definition: windns.h:111
#define DNS_QUERY_NO_WIRE_QUERY
Definition: windns.h:13
#define PDNS_RECORD
Definition: windns.h:636
#define DNS_TYPE_A
Definition: windns.h:41
char * LPSTR
Definition: xmlstorage.h:182

Referenced by R_ResolverQuery().