]> git.saurik.com Git - apple/mdnsresponder.git/blob - unittests/uds_daemon_ut.c
mDNSResponder-1096.0.2.tar.gz
[apple/mdnsresponder.git] / unittests / uds_daemon_ut.c
1 #include "DNSCommon.h" // Defines general DNS utility routines
2 #include "unittest_common.h"
3
4 mDNSexport mStatus handle_client_request_ut(void *req)
5 {
6 return handle_client_request((request_state*)req);
7 }
8
9 mDNSexport void LogCacheRecords_ut(mDNSs32 now, mDNSu32* retCacheUsed, mDNSu32* retCacheActive)
10 {
11 mDNSu32 CacheUsed =0, CacheActive =0, slot;
12 const CacheGroup *cg;
13 const CacheRecord *cr;
14
15 LogMsgNoIdent("------------ Cache -------------");
16 LogMsgNoIdent("Slt Q TTL if U Type rdlen");
17 for (slot = 0; slot < CACHE_HASH_SLOTS; slot++)
18 {
19 for (cg = mDNSStorage.rrcache_hash[slot]; cg; cg=cg->next)
20 {
21 CacheUsed++; // Count one cache entity for the CacheGroup object
22 for (cr = cg->members; cr; cr=cr->next)
23 {
24 const mDNSs32 remain = cr->resrec.rroriginalttl - (now - cr->TimeRcvd) / mDNSPlatformOneSecond;
25 const char *ifname;
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);
33 }
34 }
35 }
36
37 *retCacheUsed = CacheUsed;
38 *retCacheActive = CacheActive;
39 }
40
41 mDNSexport int LogEtcHosts_ut(mDNS *const m)
42 {
43 return LogEtcHostsToFD(STDOUT_FILENO, m);
44 }