]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSCore/mDNSPlatformFunctions.h
mDNSResponder-22.tar.gz
[apple/mdnsresponder.git] / mDNSCore / mDNSPlatformFunctions.h
1 // ***************************************************************************
2 // Support functions which must be provided by each set of specific PlatformSupport files
3
4 // mDNSPlatformInit() typically opens a communication endpoint, and starts listening for mDNS packets.
5 // When Setup is complete, the callback is called.
6 // mDNSPlatformSendUDP() sends one UDP packet
7 // When a packet is received, the PlatformSupport code calls mDNSCoreReceive()
8 // mDNSPlatformScheduleTask() indicates that a timer should be set,
9 // and mDNSCoreTask() should be called when the timer expires
10 // mDNSPlatformClose() tidies up on exit
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 // ***************************************************************************
17 // DNS protocol message format
18
19 typedef struct
20 {
21 mDNSOpaque16 id;
22 mDNSOpaque16 flags;
23 mDNSu16 numQuestions;
24 mDNSu16 numAnswers;
25 mDNSu16 numAuthorities;
26 mDNSu16 numAdditionals;
27 } DNSMessageHeader;
28
29 // We can send and receive packets up to 9000 bytes (Ethernet Jumbo Frame size, if that ever becomes widely used)
30 // However, in the normal case we try to limit packets to 1500 bytes so that we don't get IP fragmentation on standard Ethernet
31 #define AbsoluteMaxDNSMessageData 8960
32 #define NormalMaxDNSMessageData 1460
33 typedef struct
34 {
35 DNSMessageHeader h; // Note: Size 12 bytes
36 mDNSu8 data[AbsoluteMaxDNSMessageData]; // 20 (IP) + 8 (UDP) + 12 (header) + 8960 (data) = 9000
37 } DNSMessage;
38
39 // ***************************************************************************
40 // Functions
41
42 // Every platform support module must provide the following functions
43 extern mStatus mDNSPlatformInit (mDNS *const m);
44 extern void mDNSPlatformClose (mDNS *const m);
45 extern mStatus mDNSPlatformSendUDP(const mDNS *const m, const DNSMessage *const msg, const mDNSu8 *const end,
46 mDNSIPAddr src, mDNSIPPort srcport, mDNSIPAddr dst, mDNSIPPort dstport);
47
48 extern void mDNSPlatformScheduleTask(const mDNS *const m, mDNSs32 NextTaskTime);
49 extern void mDNSPlatformLock (const mDNS *const m);
50 extern void mDNSPlatformUnlock (const mDNS *const m);
51
52 extern void mDNSPlatformStrCopy(const void *src, void *dst);
53 extern mDNSu32 mDNSPlatformStrLen (const void *src);
54 extern void mDNSPlatformMemCopy(const void *src, void *dst, mDNSu32 len);
55 extern mDNSBool mDNSPlatformMemSame(const void *src, const void *dst, mDNSu32 len);
56 extern void mDNSPlatformMemZero( void *dst, mDNSu32 len);
57 extern mDNSs32 mDNSPlatformTimeNow();
58 extern mDNSs32 mDNSPlatformOneSecond;
59
60 // The core mDNS code provides these functions, for the platform support code to call at appropriate times
61 extern void mDNSCoreInitComplete(mDNS *const m, mStatus result);
62 extern void mDNSCoreReceive(mDNS *const m, DNSMessage *const msg, const mDNSu8 *const end,
63 mDNSIPAddr srcaddr, mDNSIPPort srcport, mDNSIPAddr dstaddr, mDNSIPPort dstport, mDNSIPAddr InterfaceAddr);
64 extern void mDNSCoreTask (mDNS *const m);
65 extern void mDNSCoreSleep (mDNS *const m, mDNSBool wake);
66
67 #ifdef __cplusplus
68 }
69 #endif