1 #include "DNSCommon.h" // Defines general DNS utility routines
2 #include "unittest_common.h"
4 mDNSexport mStatus
handle_client_request_ut(void *req
)
6 return handle_client_request((request_state
*)req
);
9 mDNSexport
void LogCacheRecords_ut(mDNSs32 now
, mDNSu32
* retCacheUsed
, mDNSu32
* retCacheActive
)
11 mDNSu32 CacheUsed
=0, CacheActive
=0, slot
;
13 const CacheRecord
*cr
;
15 LogMsgNoIdent("------------ Cache -------------");
16 LogMsgNoIdent("Slt Q TTL if U Type rdlen");
17 for (slot
= 0; slot
< CACHE_HASH_SLOTS
; slot
++)
19 for (cg
= mDNSStorage
.rrcache_hash
[slot
]; cg
; cg
=cg
->next
)
21 CacheUsed
++; // Count one cache entity for the CacheGroup object
22 for (cr
= cg
->members
; cr
; cr
=cr
->next
)
24 const mDNSs32 remain
= cr
->resrec
.rroriginalttl
- (now
- cr
->TimeRcvd
) / mDNSPlatformOneSecond
;
26 mDNSInterfaceID InterfaceID
= cr
->resrec
.InterfaceID
;
27 if (!InterfaceID
&& cr
->resrec
.rDNSServer
&& (cr
->resrec
.rDNSServer
->scopeType
!= kScopeNone
))
28 InterfaceID
= cr
->resrec
.rDNSServer
->interface
;
29 ifname
= InterfaceNameForID(&mDNSStorage
, InterfaceID
);
30 if (cr
->CRActiveQuestion
) CacheActive
++;
31 PrintOneCacheRecordToFD(STDOUT_FILENO
, cr
, slot
, remain
, ifname
, &CacheUsed
);
32 PrintCachedRecordsToFD(STDOUT_FILENO
, cr
, slot
, remain
, ifname
, &CacheUsed
);
37 *retCacheUsed
= CacheUsed
;
38 *retCacheActive
= CacheActive
;
41 mDNSexport
int LogEtcHosts_ut(mDNS
*const m
)
43 return LogEtcHostsToFD(STDOUT_FILENO
, m
);