1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2007-2019 Apple Inc. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #define kHelperService "com.apple.mDNSResponder_Helper"
25 #define kmDNSHelperProgramArgs CFSTR("com.apple.mDNSResponderHelper")
26 #define kPreferencesKey_mDNSHelperLog CFSTR("mDNSHelperDebugLogging")
28 #define kHelperMode "HelperMode"
29 #define kHelperReplyStatus "HelperReplyStatusToClient"
30 #define kHelperErrCode "HelperErrorCodefromCall"
32 #define kPrefsNameKey "PreferencesNameKey"
33 #define kPrefsOldName "PreferencesOldName"
34 #define kPrefsNewName "PreferencesNewName"
36 extern int mDNSHelperLogEnabled
;
38 extern os_log_t log_handle
;
48 set_localaddr_cacheentry
= 7,
51 keychain_getsecrets
= 10,
57 } HelperReplyStatusCodes
;
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,
86 enum mDNSPreferencesSetNameKey
88 kmDNSComputerName
= 1,
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
103 kmDNSKcWhere
, // Where
104 kmDNSKcAccount
, // Account
109 #include "mDNSEmbeddedAPI.h"
110 #include "helpermsg-types.h"
112 extern const char *mDNSHelperError(int errornum
);
114 extern mStatus
mDNSHelperInit(void);
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
);
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);
142 #endif /* H_HELPER_H */