2 * Purple is the legal property of its developers, whose names are too numerous
3 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
20 #ifndef PURPLE_BONJOUR_DNS_SD_PROXY_H
21 #define PURPLE_BONJOUR_DNS_SD_PROXY_H
27 /* The following is a subset of Apple's dns_sd.h file
28 * http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-333.10/mDNSShared/dns_sd.h
30 * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions are met:
35 * 1. Redistributions of source code must retain the above copyright notice,
36 * this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright notice,
38 * this list of conditions and the following disclaimer in the documentation
39 * and/or other materials provided with the distribution.
40 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
41 * contributors may be used to endorse or promote products derived from this
42 * software without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
45 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
46 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
47 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
48 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
53 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 # if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
57 # define DNSSD_API __stdcall
62 # define kDNSServiceInterfaceIndexAny 0
63 # define kDNSServiceMaxDomainName 1009
65 typedef gint32 DNSServiceErrorType
;
66 typedef guint32 DNSServiceFlags
;
67 typedef struct _DNSServiceRef_t
*DNSServiceRef
;
68 typedef struct _DNSRecordRef_t
*DNSRecordRef
;
69 typedef guint32 DNSServiceProtocol
;
71 typedef union _TXTRecordRef_t
{
72 gchar PrivateData
[16];
73 gchar
*ForceNaturalAlignment
;
76 typedef void (DNSSD_API
*DNSServiceBrowseReply
)();
77 typedef void (DNSSD_API
*DNSServiceGetAddrInfoReply
)();
78 typedef void (DNSSD_API
*DNSServiceQueryRecordReply
)(
79 DNSServiceRef sdRef
, DNSServiceFlags flags
, guint32 interfaceIndex
,
80 DNSServiceErrorType errorCode
, const gchar
*fullname
,
81 guint16 rrtype
, guint16 rrclass
, guint16 rdlen
, const void *rdata
,
82 guint32 ttl
, void *context
);
83 typedef void (DNSSD_API
*DNSServiceRegisterReply
)();
84 typedef void (DNSSD_API
*DNSServiceResolveReply
)(
85 DNSServiceRef sdRef
, DNSServiceFlags flags
, guint32 interfaceIndex
,
86 DNSServiceErrorType errorCode
, const gchar
*fullname
,
87 const gchar
*hosttarget
, guint16 port
, guint16 txtLen
,
88 const guchar
*txtRecord
, void *context
);
91 kDNSServiceErr_NoError
= 0,
92 kDNSServiceErr_Unknown
= -65537,
96 kDNSServiceFlagsAdd
= 0x2,
97 kDNSServiceFlagsLongLivedQuery
= 0x100,
101 kDNSServiceType_NULL
= 10,
102 kDNSServiceType_TXT
= 16,
106 kDNSServiceClass_IN
= 1,
110 kDNSServiceProtocol_IPv4
= 0x01,
114 gboolean
dns_sd_available(void);
116 DNSServiceErrorType
_wpurple_DNSServiceAddRecord(DNSServiceRef sdRef
, DNSRecordRef
*RecordRef
, DNSServiceFlags flags
,
117 uint16_t rrtype
, uint16_t rdlen
, const void *rdata
, uint32_t ttl
);
118 #define DNSServiceAddRecord(sdRef, RecordRef, flags, rrtype, rdlen, rdata, ttl) \
119 _wpurple_DNSServiceAddRecord(sdRef, RecordRef, flags, rrtype, rdlen, rdata, ttl)
121 DNSServiceErrorType
_wpurple_DNSServiceBrowse(DNSServiceRef
*sdRef
, DNSServiceFlags flags
, uint32_t interfaceIndex
,
122 const char *regtype
, const char *domain
, DNSServiceBrowseReply callBack
, void *context
);
123 #define DNSServiceBrowse(sdRef, flags, interfaceIndex, regtype, domain, callBack, context) \
124 _wpurple_DNSServiceBrowse(sdRef, flags, interfaceIndex, regtype, domain, callBack, context)
126 int _wpurple_DNSServiceConstructFullName(char *fullName
, const char *service
, const char *regtype
, const char *domain
);
127 #define DNSServiceConstructFullName(fullName, service, regtype, domain) \
128 _wpurple_DNSServiceConstructFullName(fullName, service, regtype, domain)
130 DNSServiceErrorType
_wpurple_DNSServiceGetAddrInfo(DNSServiceRef
*sdRef
, DNSServiceFlags flags
, uint32_t interfaceIndex
,
131 DNSServiceProtocol protocol
, const char *hostname
, DNSServiceGetAddrInfoReply callBack
, void *context
);
132 #define DNSServiceGetAddrInfo(sdRef, flags, interfaceIndex, protocol, hostname, callBack, context) \
133 _wpurple_DNSServiceGetAddrInfo(sdRef, flags, interfaceIndex, protocol, hostname, callBack, context)
135 DNSServiceErrorType
_wpurple_DNSServiceProcessResult(DNSServiceRef sdRef
);
136 #define DNSServiceProcessResult(sdRef) \
137 _wpurple_DNSServiceProcessResult(sdRef);
139 DNSServiceErrorType
_wpurple_DNSServiceQueryRecord(DNSServiceRef
*sdRef
, DNSServiceFlags flags
, uint32_t interfaceIndex
,
140 const char *fullname
, uint16_t rrtype
, uint16_t rrclass
, DNSServiceQueryRecordReply callBack
, void *context
);
141 #define DNSServiceQueryRecord(sdRef, flags, interfaceIndex, fullname, rrtype, rrclass, callBack, context) \
142 _wpurple_DNSServiceQueryRecord(sdRef, flags, interfaceIndex, fullname, rrtype, rrclass, callBack, context)
144 void _wpurple_DNSServiceRefDeallocate(DNSServiceRef sdRef
);
145 #define DNSServiceRefDeallocate(sdRef) \
146 _wpurple_DNSServiceRefDeallocate(sdRef)
148 int _wpurple_DNSServiceRefSockFD(DNSServiceRef sdRef
);
149 #define DNSServiceRefSockFD(sdRef) \
150 _wpurple_DNSServiceRefSockFD(sdRef)
152 DNSServiceErrorType
_wpurple_DNSServiceRegister(DNSServiceRef
*sdRef
, DNSServiceFlags flags
, uint32_t interfaceIndex
,
153 const char *name
, const char *regtype
, const char *domain
, const char *host
, uint16_t port
, uint16_t txtLen
,
154 const void *txtRecord
, DNSServiceRegisterReply callBack
, void *context
);
155 #define DNSServiceRegister(sdRef, flags, interfaceIndex, name, regtype, domain, host, port, txtLen, txtRecord, callBack, context) \
156 _wpurple_DNSServiceRegister(sdRef, flags, interfaceIndex, name, regtype, domain, host, port, txtLen, txtRecord, callBack, context)
158 DNSServiceErrorType
_wpurple_DNSServiceResolve(DNSServiceRef
*sdRef
, DNSServiceFlags flags
, uint32_t interfaceIndex
, const char *name
,
159 const char *regtype
, const char *domain
, DNSServiceResolveReply callBack
, void *context
);
160 #define DNSServiceResolve(sdRef, flags, interfaceIndex, name, regtype, domain, callBack, context) \
161 _wpurple_DNSServiceResolve(sdRef, flags, interfaceIndex, name, regtype, domain, callBack, context)
163 DNSServiceErrorType
_wpurple_DNSServiceRemoveRecord(DNSServiceRef sdRef
, DNSRecordRef RecordRef
, DNSServiceFlags flags
);
164 #define DNSServiceRemoveRecord(sdRef, RecordRef, flags) \
165 _wpurple_DNSServiceRemoveRecord(sdRef, RecordRef, flags)
167 DNSServiceErrorType
_wpurple_DNSServiceUpdateRecord(DNSServiceRef sdRef
, DNSRecordRef RecordRef
, DNSServiceFlags flags
,
168 uint16_t rdlen
, const void *rdata
, uint32_t ttl
);
169 #define DNSServiceUpdateRecord(sdRef, RecordRef, flags, rdlen, rdata, ttl) \
170 _wpurple_DNSServiceUpdateRecord(sdRef, RecordRef, flags, rdlen, rdata, ttl)
172 void _wpurple_TXTRecordCreate(TXTRecordRef
*txtRecord
, uint16_t bufferLen
, void *buffer
);
173 #define TXTRecordCreate(txtRecord, bufferLen, buffer) \
174 _wpurple_TXTRecordCreate(txtRecord, bufferLen, buffer)
176 void _wpurple_TXTRecordDeallocate(TXTRecordRef
*txtRecord
);
177 #define TXTRecordDeallocate(txtRecord) \
178 _wpurple_TXTRecordDeallocate(txtRecord)
180 const void * _wpurple_TXTRecordGetBytesPtr(const TXTRecordRef
*txtRecord
);
181 #define TXTRecordGetBytesPtr(txtRecord) \
182 _wpurple_TXTRecordGetBytesPtr(txtRecord)
184 uint16_t _wpurple_TXTRecordGetLength(const TXTRecordRef
*txtRecord
);
185 #define TXTRecordGetLength(txtRecord) \
186 _wpurple_TXTRecordGetLength(txtRecord)
188 const void * _wpurple_TXTRecordGetValuePtr(uint16_t txtLen
, const void *txtRecord
, const char *key
, uint8_t *valueLen
);
189 #define TXTRecordGetValuePtr(txtLen, txtRecord, key, valueLen) \
190 _wpurple_TXTRecordGetValuePtr(txtLen, txtRecord, key, valueLen)
192 DNSServiceErrorType
_wpurple_TXTRecordSetValue(TXTRecordRef
*txtRecord
, const char *key
, uint8_t valueSize
, const void *value
);
193 #define TXTRecordSetValue(txtRecord, key, valueSize, value) \
194 _wpurple_TXTRecordSetValue(txtRecord, key, valueSize, value)
196 #endif /* PURPLE_BONJOUR_DNS_SD_PROXY_H */