1 | /* -*- Mode: C; tab-width: 4 -*- |
---|
2 | * |
---|
3 | * Copyright (c) 2002, 2004, 2006, 2011 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 | /*! @header DNS Service Discovery (Deprecated Mach-based API) |
---|
19 | * |
---|
20 | * @discussion Note that this API was deprecated in Mac OS X 10.3, and replaced |
---|
21 | * by the portable cross-platform /usr/include/dns_sd.h API. |
---|
22 | */ |
---|
23 | |
---|
24 | #ifndef __DNS_SERVICE_DISCOVERY_H |
---|
25 | #define __DNS_SERVICE_DISCOVERY_H |
---|
26 | |
---|
27 | #include <mach/mach_types.h> |
---|
28 | |
---|
29 | #include <sys/types.h> |
---|
30 | #include <sys/socket.h> |
---|
31 | #include <sys/cdefs.h> |
---|
32 | |
---|
33 | #include <netinet/in.h> |
---|
34 | |
---|
35 | #include <AvailabilityMacros.h> |
---|
36 | |
---|
37 | __BEGIN_DECLS |
---|
38 | |
---|
39 | /* Opaque internal data type */ |
---|
40 | typedef struct _dns_service_discovery_t * dns_service_discovery_ref; |
---|
41 | |
---|
42 | /* possible reply flags values */ |
---|
43 | |
---|
44 | enum { |
---|
45 | kDNSServiceDiscoveryNoFlags = 0, |
---|
46 | kDNSServiceDiscoveryMoreRepliesImmediately = 1 << 0, |
---|
47 | }; |
---|
48 | |
---|
49 | |
---|
50 | typedef enum |
---|
51 | { |
---|
52 | DNSServiceDomainEnumerationReplyAddDomain, |
---|
53 | DNSServiceDomainEnumerationReplyAddDomainDefault, |
---|
54 | DNSServiceDomainEnumerationReplyRemoveDomain, |
---|
55 | } DNSServiceDomainEnumerationReplyResultType; |
---|
56 | |
---|
57 | typedef enum |
---|
58 | { |
---|
59 | DNSServiceDiscoverReplyFlagsFinished, |
---|
60 | DNSServiceDiscoverReplyFlagsMoreComing, |
---|
61 | } DNSServiceDiscoveryReplyFlags; |
---|
62 | |
---|
63 | typedef void (*DNSServiceDomainEnumerationReply)( |
---|
64 | DNSServiceDomainEnumerationReplyResultType resultType, // One of DNSServiceDomainEnumerationReplyResultType |
---|
65 | const char *replyDomain, |
---|
66 | DNSServiceDiscoveryReplyFlags flags, // DNS Service Discovery reply flags information |
---|
67 | void *context |
---|
68 | ); |
---|
69 | |
---|
70 | |
---|
71 | /* possible error code values */ |
---|
72 | typedef enum |
---|
73 | { |
---|
74 | kDNSServiceDiscoveryNoError = 0, |
---|
75 | } DNSServiceRegistrationReplyErrorType; |
---|
76 | |
---|
77 | typedef void (*DNSServiceRegistrationReply)( |
---|
78 | DNSServiceRegistrationReplyErrorType errorCode, |
---|
79 | void *context |
---|
80 | ); |
---|
81 | |
---|
82 | typedef uint32_t DNSRecordReference; |
---|
83 | |
---|
84 | |
---|
85 | /*! |
---|
86 | @function DNSServiceResolver_handleReply |
---|
87 | @discussion This function should be called with the Mach message sent |
---|
88 | to the port returned by the call to DNSServiceResolverResolve. |
---|
89 | The reply message will be interpreted and will result in a |
---|
90 | call to the specified callout function. |
---|
91 | @param replyMsg The Mach message. |
---|
92 | */ |
---|
93 | void DNSServiceDiscovery_handleReply(void *replyMsg); |
---|
94 | |
---|
95 | /***************************************************************************/ |
---|
96 | /* DNS Service Browser */ |
---|
97 | |
---|
98 | typedef enum |
---|
99 | { |
---|
100 | DNSServiceBrowserReplyAddInstance, // Instance of service found |
---|
101 | DNSServiceBrowserReplyRemoveInstance // Instance has been removed from network |
---|
102 | } DNSServiceBrowserReplyResultType; |
---|
103 | |
---|
104 | typedef void (*DNSServiceBrowserReply)( |
---|
105 | DNSServiceBrowserReplyResultType resultType, // One of DNSServiceBrowserReplyResultType |
---|
106 | const char *replyName, |
---|
107 | const char *replyType, |
---|
108 | const char *replyDomain, |
---|
109 | DNSServiceDiscoveryReplyFlags flags, // DNS Service Discovery reply flags information |
---|
110 | void *context |
---|
111 | ); |
---|
112 | |
---|
113 | /*! |
---|
114 | @function DNSServiceBrowserCreate |
---|
115 | @discussion Asynchronously create a DNS Service browser |
---|
116 | @param regtype The type of service |
---|
117 | @param domain The domain in which to find the service |
---|
118 | @param callBack The function to be called when service instances are found or removed |
---|
119 | @param context A user specified context which will be passed to the callout function. |
---|
120 | @result A dns_registration_t |
---|
121 | */ |
---|
122 | dns_service_discovery_ref DNSServiceBrowserCreate |
---|
123 | ( |
---|
124 | const char *regtype, |
---|
125 | const char *domain, |
---|
126 | DNSServiceBrowserReply callBack, |
---|
127 | void *context |
---|
128 | ) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3; |
---|
129 | |
---|
130 | /***************************************************************************/ |
---|
131 | /* Resolver requests */ |
---|
132 | |
---|
133 | typedef void (*DNSServiceResolverReply)( |
---|
134 | struct sockaddr *interface, // Needed for scoped addresses like link-local |
---|
135 | struct sockaddr *address, |
---|
136 | const char *txtRecord, |
---|
137 | DNSServiceDiscoveryReplyFlags flags, // DNS Service Discovery reply flags information |
---|
138 | void *context |
---|
139 | ); |
---|
140 | |
---|
141 | /*! |
---|
142 | @function DNSServiceResolverResolve |
---|
143 | @discussion Resolved a named instance of a service to its address, port, and |
---|
144 | (optionally) other demultiplexing information contained in the TXT record. |
---|
145 | @param name The name of the service instance |
---|
146 | @param regtype The type of service |
---|
147 | @param domain The domain in which to find the service |
---|
148 | @param callBack The DNSServiceResolverReply function to be called when the specified |
---|
149 | address has been resolved. |
---|
150 | @param context A user specified context which will be passed to the callout function. |
---|
151 | @result A dns_registration_t |
---|
152 | */ |
---|
153 | |
---|
154 | dns_service_discovery_ref DNSServiceResolverResolve |
---|
155 | ( |
---|
156 | const char *name, |
---|
157 | const char *regtype, |
---|
158 | const char *domain, |
---|
159 | DNSServiceResolverReply callBack, |
---|
160 | void *context |
---|
161 | ) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3; |
---|
162 | |
---|
163 | /***************************************************************************/ |
---|
164 | /* Mach port accessor and deallocation */ |
---|
165 | |
---|
166 | /*! |
---|
167 | @function DNSServiceDiscoveryMachPort |
---|
168 | @discussion Returns the mach port for a dns_service_discovery_ref |
---|
169 | @param registration A dns_service_discovery_ref as returned from DNSServiceRegistrationCreate |
---|
170 | @result A mach reply port which will be sent messages as appropriate. |
---|
171 | These messages should be passed to the DNSServiceDiscovery_handleReply |
---|
172 | function. A NULL value indicates that no address was |
---|
173 | specified or some other error occurred which prevented the |
---|
174 | resolution from being started. |
---|
175 | */ |
---|
176 | mach_port_t DNSServiceDiscoveryMachPort(dns_service_discovery_ref dnsServiceDiscovery) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3; |
---|
177 | |
---|
178 | /*! |
---|
179 | @function DNSServiceDiscoveryDeallocate |
---|
180 | @discussion Deallocates the DNS Service Discovery type / closes the connection to the server |
---|
181 | @param dnsServiceDiscovery A dns_service_discovery_ref as returned from a creation or enumeration call |
---|
182 | @result void |
---|
183 | */ |
---|
184 | void DNSServiceDiscoveryDeallocate(dns_service_discovery_ref dnsServiceDiscovery) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3; |
---|
185 | |
---|
186 | __END_DECLS |
---|
187 | |
---|
188 | #endif /* __DNS_SERVICE_DISCOVERY_H */ |
---|