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