]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/helper.h
mDNSResponder-1310.60.4.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / helper.h
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2007-2019 Apple Inc. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #ifndef H_HELPER_H
19 #define H_HELPER_H
20
21 #include <os/log.h>
22
23 #define kHelperService "com.apple.mDNSResponder_Helper"
24
25 #define kmDNSHelperProgramArgs CFSTR("com.apple.mDNSResponderHelper")
26 #define kPreferencesKey_mDNSHelperLog CFSTR("mDNSHelperDebugLogging")
27
28 #define kHelperMode "HelperMode"
29 #define kHelperReplyStatus "HelperReplyStatusToClient"
30 #define kHelperErrCode "HelperErrorCodefromCall"
31
32 #define kPrefsNameKey "PreferencesNameKey"
33 #define kPrefsOldName "PreferencesOldName"
34 #define kPrefsNewName "PreferencesNewName"
35
36 extern int mDNSHelperLogEnabled;
37
38 extern os_log_t log_handle;
39
40 typedef enum
41 {
42 bpf_request = 1,
43 set_name = 2,
44 p2p_packetfilter = 3,
45 user_notify = 4,
46 power_req = 5,
47 send_wakepkt = 6,
48 set_localaddr_cacheentry = 7,
49 send_keepalive = 8,
50 retreive_tcpinfo = 9,
51 keychain_getsecrets = 10,
52 } HelperModes;
53
54 typedef enum
55 {
56 kHelperReply_ACK = 0,
57 } HelperReplyStatusCodes;
58
59
60 typedef enum
61 {
62 kHelperErr_NoErr = 0,
63 kHelperErr_DefaultErr = -1,
64 kHelperErr_NotConnected = -2,
65 kHelperErr_NoResponse = -3,
66 kHelperErr_UndefinedMode = -4,
67 kHelperErr_ApiErr = -5,
68 kHelperErr_InvalidTunnelSetKeysOperation = -6,
69 kHelperErr_InvalidNetworkAddress = -7,
70 kHelperErr_ResultTooLarge = -8,
71 kHelperErr_RacoonConfigCreationFailed = -9,
72 kHelperErr_IPsecPolicySocketCreationFailed = -10,
73 kHelperErr_IPsecPolicyCreationFailed = -11,
74 kHelperErr_IPsecPolicySetFailed = -12,
75 kHelperErr_IPsecRemoveSAFailed = -13,
76 kHelperErr_IPsecDisabled = -14,
77 kHelperErr_RoutingSocketCreationFailed = -15,
78 kHelperErr_RouteDeletionFailed = -16,
79 kHelperErr_RouteAdditionFailed = -17,
80 kHelperErr_RacoonStartFailed = -18,
81 kHelperErr_RacoonNotificationFailed = -19,
82 kHelperErr_ParamErr = -20,
83 } HelperErrorCodes;
84
85
86 enum mDNSPreferencesSetNameKey
87 {
88 kmDNSComputerName = 1,
89 kmDNSLocalHostName
90 };
91
92 enum mDNSUpDown
93 {
94 kmDNSUp = 1,
95 kmDNSDown
96 };
97
98 // helper parses the system keychain and returns the information to mDNSResponder.
99 // It returns four attributes. Attributes are defined after how they show up in
100 // keychain access utility (the actual attribute name to retrieve these are different).
101 enum mDNSKeyChainAttributes
102 {
103 kmDNSKcWhere, // Where
104 kmDNSKcAccount, // Account
105 kmDNSKcKey, // Key
106 kmDNSKcName // Name
107 };
108
109 #include "mDNSEmbeddedAPI.h"
110 #include "helpermsg-types.h"
111
112 extern const char *mDNSHelperError(int errornum);
113
114 extern mStatus mDNSHelperInit(void);
115
116
117 extern void mDNSRequestBPF(void);
118 extern int mDNSPowerRequest(int key, int interval);
119 extern int mDNSSetLocalAddressCacheEntry(int ifindex, int family, const v6addr_t ip, const ethaddr_t eth);
120 extern void mDNSNotify(const char *title, const char *msg); // Both strings are UTF-8 text
121 extern void mDNSPreferencesSetName(int key, domainlabel *old, domainlabel *new);
122 extern int mDNSKeychainGetSecrets(CFArrayRef *secrets);
123 extern void mDNSSendWakeupPacket(unsigned ifid, char *eth_addr, char *ip_addr, int iteration);
124 extern void mDNSPacketFilterControl(uint32_t command, char * ifname, uint32_t count, pfArray_t portArray, pfArray_t protocolArray);
125 extern void mDNSSendKeepalive(const v6addr_t sadd, const v6addr_t dadd, uint16_t lport, uint16_t rport, unsigned seq, unsigned ack, uint16_t win);
126 extern int mDNSRetrieveTCPInfo(int family, v6addr_t laddr, uint16_t lport, v6addr_t raddr, uint16_t rport, uint32_t *seq, uint32_t *ack, uint16_t *win, int32_t *intfid);
127
128 extern void RequestBPF(void);
129 extern void PreferencesSetName(int key, const char* old, const char* new);
130 extern void PacketFilterControl(uint32_t command, const char * ifname, uint32_t count, pfArray_t portArray, pfArray_t protocolArray);
131 extern void UserNotify(const char *title, const char *msg); // Both strings are UTF-8 text
132 extern void PowerRequest(int key, int interval, int *error);
133 extern void SendWakeupPacket(unsigned int ifid, const char *eth_addr, const char *ip_addr, int iteration);
134 extern void SetLocalAddressCacheEntry(int ifindex, int family, const v6addr_t ip, const ethaddr_t eth, int *err);
135 extern void SendKeepalive(const v6addr_t sadd6, const v6addr_t dadd6, uint16_t lport, uint16_t rport, uint32_t seq, uint32_t ack, uint16_t win);
136 extern void RetrieveTCPInfo(int family, const v6addr_t laddr, uint16_t lport, const v6addr_t raddr, uint16_t rport, uint32_t *seq, uint32_t *ack, uint16_t *win, int32_t *intfid, int *err);
137 extern void KeychainGetSecrets(__unused unsigned int *numsecrets,__unused unsigned long *secrets, __unused unsigned int *secretsCnt, __unused int *err);
138 extern int HelperAutoTunnelSetKeys(int replacedelete, const v6addr_t loc_inner, const v6addr_t loc_outer6, uint16_t loc_port, const v6addr_t rmt_inner,
139 const v6addr_t rmt_outer6, uint16_t rmt_port, const char *id, int *err);
140 extern void helper_exit(void);
141
142 #endif /* H_HELPER_H */