1 #ifndef UNITTEST_COMMON_H
2 #define UNITTEST_COMMON_H
5 #include "uds_daemon.h"
8 #include <netdb.h> // for getaddrinfo
11 #include <CoreFoundation/CoreFoundation.h>
13 // Primary interface info that is used when simulating the receive of the response packet
14 extern mDNSInterfaceID primary_interfaceID
;
15 extern mDNSAddr primary_v4
;
16 extern mDNSAddr primary_v6
;
17 extern mDNSAddr primary_router
;
19 // Arbitrary values to simulate a client_request request
20 #define client_req_sd 12
21 #define client_req_uid 502
22 #define client_req_hdr_bytes 28
23 #define client_req_hdr_version 1
24 #define client_resp_src_port 13568
25 #define client_resp_dst_port 49339
26 #define uDNS_TargetQID 16745
27 #define client_req_process_id 15418
28 static char client_req_pid_name
[MAXCOMLEN
] = "mDNSUnitTest";
30 //Arbitrary values to simulate a DNS server
31 #define dns_server_timeout 30
32 #define dns_server_resGroupID 12
33 static const mDNSv4Addr dns_server_ipv4
= {{ 192, 168, 1, 20 }};
35 extern mStatus
init_mdns_environment(mDNSBool enableLogging
);
36 extern mStatus
init_mdns_storage(void);
37 extern size_t get_reply_len(char* name
, uint16_t rdlen
);
38 extern mStatus
start_client_request(request_state
* req
, char *msgbuf
, size_t msgsz
, uint32_t op
, UDPSocket
* socket
);
39 extern void receive_response(const request_state
* req
, DNSMessage
*msg
, size_t msgSize
);
40 extern void receive_suspicious_response_ut(const request_state
* req
, DNSMessage
*msg
, size_t msgSize
, mDNSOpaque16 suspiciousqid
, mDNSBool goodLastQID
);
41 extern void get_ip(const char *const name
, struct sockaddr_storage
*result
);
42 extern void free_req(request_state
* req
);
44 extern mStatus
mDNS_InitStorage_ut(mDNS
*const m
, mDNS_PlatformSupport
*const p
,
45 CacheEntity
*rrcachestorage
, mDNSu32 rrcachesize
,
46 mDNSBool AdvertiseLocalAddresses
, mDNSCallback
*Callback
, void *Context
);
47 extern void init_logging_ut(void);
48 extern void SetInterfaces_ut(mDNSInterfaceID
* primary_interfaceID
, mDNSAddr
*primary_v4
,
49 mDNSAddr
* primary_v6
, mDNSAddr
* primary_router
);
50 extern mStatus
handle_client_request_ut(void *req
);
51 extern void LogCacheRecords_ut(mDNSs32 now
, mDNSu32
* retCacheUsed
, mDNSu32
* retCacheActive
);
52 extern int LogEtcHosts_ut(mDNS
*const m
);
53 extern mDNSBool
mDNSMacOSXCreateEtcHostsEntry_ut(const domainname
*domain
, const struct sockaddr
*sa
,
54 const domainname
*cname
, char *ifname
, AuthHash
*auth
);
55 extern void UpdateEtcHosts_ut(void *context
);
56 extern mStatus
AddDNSServer_ut(void);
57 extern mStatus
AddDNSServerScoped_ut(mDNSInterfaceID interfaceID
, ScopeType scoped
);
58 extern mStatus
force_uDNS_SetupDNSConfig_ut(mDNS
*const m
);
59 extern mStatus
verify_cache_addr_order_for_domain_ut(mDNS
*const m
, mDNSu8
* octet
, mDNSu32 count
, const domainname
*const name
);
62 extern void mDNSDomainLabelFromCFString_ut(CFStringRef cfs
, domainlabel
*const namelabel
);
64 #endif /* UNITTEST_COMMON_H */