libpurple/protocols/bonjour/dns_sd_proxy.h

changeset 42670
a3b862b8dcde
parent 42669
6d41b29637ef
child 42671
68cc8544b438
equal deleted inserted replaced
42669:6d41b29637ef 42670:a3b862b8dcde
1 /*
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
4 * source distribution.
5 *
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.
10 *
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.
15 *
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.
19 */
20 #ifndef PURPLE_BONJOUR_DNS_SD_PROXY_H
21 #define PURPLE_BONJOUR_DNS_SD_PROXY_H
22
23 #include <stdint.h>
24
25 /* The following is a subset of Apple's dns_sd.h file
26 * http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-333.10/mDNSShared/dns_sd.h
27 *
28 * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions are met:
32 *
33 * 1. Redistributions of source code must retain the above copyright notice,
34 * this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright notice,
36 * this list of conditions and the following disclaimer in the documentation
37 * and/or other materials provided with the distribution.
38 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
39 * contributors may be used to endorse or promote products derived from this
40 * software without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
43 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
44 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
46 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
47 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
51 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 */
53
54 # if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
55 # define DNSSD_API __stdcall
56 # else
57 # define DNSSD_API
58 # endif
59
60 # define kDNSServiceInterfaceIndexAny 0
61 # define kDNSServiceMaxDomainName 1009
62
63 typedef gint32 DNSServiceErrorType;
64 typedef guint32 DNSServiceFlags;
65 typedef struct _DNSServiceRef_t *DNSServiceRef;
66 typedef struct _DNSRecordRef_t *DNSRecordRef;
67 typedef guint32 DNSServiceProtocol;
68
69 typedef union _TXTRecordRef_t {
70 gchar PrivateData[16];
71 gchar *ForceNaturalAlignment;
72 } TXTRecordRef;
73
74 typedef void (DNSSD_API *DNSServiceBrowseReply)();
75 typedef void (DNSSD_API *DNSServiceGetAddrInfoReply)();
76 typedef void (DNSSD_API *DNSServiceQueryRecordReply)(
77 DNSServiceRef sdRef, DNSServiceFlags flags, guint32 interfaceIndex,
78 DNSServiceErrorType errorCode, const gchar *fullname,
79 guint16 rrtype, guint16 rrclass, guint16 rdlen, const void *rdata,
80 guint32 ttl, void *context);
81 typedef void (DNSSD_API *DNSServiceRegisterReply)();
82 typedef void (DNSSD_API *DNSServiceResolveReply)(
83 DNSServiceRef sdRef, DNSServiceFlags flags, guint32 interfaceIndex,
84 DNSServiceErrorType errorCode, const gchar *fullname,
85 const gchar *hosttarget, guint16 port, guint16 txtLen,
86 const guchar *txtRecord, void *context);
87
88 enum {
89 kDNSServiceErr_NoError = 0,
90 kDNSServiceErr_Unknown = -65537,
91 };
92
93 enum {
94 kDNSServiceFlagsAdd = 0x2,
95 kDNSServiceFlagsLongLivedQuery = 0x100,
96 };
97
98 enum {
99 kDNSServiceType_NULL = 10,
100 kDNSServiceType_TXT = 16,
101 };
102
103 enum {
104 kDNSServiceClass_IN = 1,
105 };
106
107 enum {
108 kDNSServiceProtocol_IPv4 = 0x01,
109 };
110
111
112 gboolean dns_sd_available(void);
113
114 DNSServiceErrorType _wpurple_DNSServiceAddRecord(DNSServiceRef sdRef, DNSRecordRef *RecordRef, DNSServiceFlags flags,
115 uint16_t rrtype, uint16_t rdlen, const void *rdata, uint32_t ttl);
116 #define DNSServiceAddRecord(sdRef, RecordRef, flags, rrtype, rdlen, rdata, ttl) \
117 _wpurple_DNSServiceAddRecord(sdRef, RecordRef, flags, rrtype, rdlen, rdata, ttl)
118
119 DNSServiceErrorType _wpurple_DNSServiceBrowse(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
120 const char *regtype, const char *domain, DNSServiceBrowseReply callBack, void *context);
121 #define DNSServiceBrowse(sdRef, flags, interfaceIndex, regtype, domain, callBack, context) \
122 _wpurple_DNSServiceBrowse(sdRef, flags, interfaceIndex, regtype, domain, callBack, context)
123
124 int _wpurple_DNSServiceConstructFullName(char *fullName, const char *service, const char *regtype, const char *domain);
125 #define DNSServiceConstructFullName(fullName, service, regtype, domain) \
126 _wpurple_DNSServiceConstructFullName(fullName, service, regtype, domain)
127
128 DNSServiceErrorType _wpurple_DNSServiceGetAddrInfo(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
129 DNSServiceProtocol protocol, const char *hostname, DNSServiceGetAddrInfoReply callBack, void *context);
130 #define DNSServiceGetAddrInfo(sdRef, flags, interfaceIndex, protocol, hostname, callBack, context) \
131 _wpurple_DNSServiceGetAddrInfo(sdRef, flags, interfaceIndex, protocol, hostname, callBack, context)
132
133 DNSServiceErrorType _wpurple_DNSServiceProcessResult(DNSServiceRef sdRef);
134 #define DNSServiceProcessResult(sdRef) \
135 _wpurple_DNSServiceProcessResult(sdRef);
136
137 DNSServiceErrorType _wpurple_DNSServiceQueryRecord(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
138 const char *fullname, uint16_t rrtype, uint16_t rrclass, DNSServiceQueryRecordReply callBack, void *context);
139 #define DNSServiceQueryRecord(sdRef, flags, interfaceIndex, fullname, rrtype, rrclass, callBack, context) \
140 _wpurple_DNSServiceQueryRecord(sdRef, flags, interfaceIndex, fullname, rrtype, rrclass, callBack, context)
141
142 void _wpurple_DNSServiceRefDeallocate(DNSServiceRef sdRef);
143 #define DNSServiceRefDeallocate(sdRef) \
144 _wpurple_DNSServiceRefDeallocate(sdRef)
145
146 int _wpurple_DNSServiceRefSockFD(DNSServiceRef sdRef);
147 #define DNSServiceRefSockFD(sdRef) \
148 _wpurple_DNSServiceRefSockFD(sdRef)
149
150 DNSServiceErrorType _wpurple_DNSServiceRegister(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
151 const char *name, const char *regtype, const char *domain, const char *host, uint16_t port, uint16_t txtLen,
152 const void *txtRecord, DNSServiceRegisterReply callBack, void *context);
153 #define DNSServiceRegister(sdRef, flags, interfaceIndex, name, regtype, domain, host, port, txtLen, txtRecord, callBack, context) \
154 _wpurple_DNSServiceRegister(sdRef, flags, interfaceIndex, name, regtype, domain, host, port, txtLen, txtRecord, callBack, context)
155
156 DNSServiceErrorType _wpurple_DNSServiceResolve(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, const char *name,
157 const char *regtype, const char *domain, DNSServiceResolveReply callBack, void *context);
158 #define DNSServiceResolve(sdRef, flags, interfaceIndex, name, regtype, domain, callBack, context) \
159 _wpurple_DNSServiceResolve(sdRef, flags, interfaceIndex, name, regtype, domain, callBack, context)
160
161 DNSServiceErrorType _wpurple_DNSServiceRemoveRecord(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags);
162 #define DNSServiceRemoveRecord(sdRef, RecordRef, flags) \
163 _wpurple_DNSServiceRemoveRecord(sdRef, RecordRef, flags)
164
165 DNSServiceErrorType _wpurple_DNSServiceUpdateRecord(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags,
166 uint16_t rdlen, const void *rdata, uint32_t ttl);
167 #define DNSServiceUpdateRecord(sdRef, RecordRef, flags, rdlen, rdata, ttl) \
168 _wpurple_DNSServiceUpdateRecord(sdRef, RecordRef, flags, rdlen, rdata, ttl)
169
170 void _wpurple_TXTRecordCreate(TXTRecordRef *txtRecord, uint16_t bufferLen, void *buffer);
171 #define TXTRecordCreate(txtRecord, bufferLen, buffer) \
172 _wpurple_TXTRecordCreate(txtRecord, bufferLen, buffer)
173
174 void _wpurple_TXTRecordDeallocate(TXTRecordRef *txtRecord);
175 #define TXTRecordDeallocate(txtRecord) \
176 _wpurple_TXTRecordDeallocate(txtRecord)
177
178 const void * _wpurple_TXTRecordGetBytesPtr(const TXTRecordRef *txtRecord);
179 #define TXTRecordGetBytesPtr(txtRecord) \
180 _wpurple_TXTRecordGetBytesPtr(txtRecord)
181
182 uint16_t _wpurple_TXTRecordGetLength(const TXTRecordRef *txtRecord);
183 #define TXTRecordGetLength(txtRecord) \
184 _wpurple_TXTRecordGetLength(txtRecord)
185
186 const void * _wpurple_TXTRecordGetValuePtr(uint16_t txtLen, const void *txtRecord, const char *key, uint8_t *valueLen);
187 #define TXTRecordGetValuePtr(txtLen, txtRecord, key, valueLen) \
188 _wpurple_TXTRecordGetValuePtr(txtLen, txtRecord, key, valueLen)
189
190 DNSServiceErrorType _wpurple_TXTRecordSetValue(TXTRecordRef *txtRecord, const char *key, uint8_t valueSize, const void *value);
191 #define TXTRecordSetValue(txtRecord, key, valueSize, value) \
192 _wpurple_TXTRecordSetValue(txtRecord, key, valueSize, value)
193
194 #endif /* PURPLE_BONJOUR_DNS_SD_PROXY_H */

mercurial