4b22b9337f359bfd063322244f5336cc7c6ffcfars/* -*- Mode: C; tab-width: 4 -*-
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * Copyright (c) 2003-2015 Apple Inc. All rights reserved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Redistribution and use in source and binary forms, with or without
4b22b9337f359bfd063322244f5336cc7c6ffcfars * modification, are permitted provided that the following conditions are met:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 1. Redistributions of source code must retain the above copyright notice,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * this list of conditions and the following disclaimer.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 2. Redistributions in binary form must reproduce the above copyright notice,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * this list of conditions and the following disclaimer in the documentation
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and/or other materials provided with the distribution.
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * contributors may be used to endorse or promote products derived from this
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * software without specific prior written permission.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4b22b9337f359bfd063322244f5336cc7c6ffcfars * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*! @header DNS Service Discovery
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * @discussion This section describes the functions, callbacks, and data structures
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * that make up the DNS Service Discovery API.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The DNS Service Discovery API is part of Bonjour, Apple's implementation
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * of zero-configuration networking (ZEROCONF).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Bonjour allows you to register a network service, such as a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * printer or file server, so that it can be found by name or browsed
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * for by service type and domain. Using Bonjour, applications can
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * discover what services are available on the network, along with
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * all the information -- such as name, IP address, and port --
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * necessary to access a particular service.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * In effect, Bonjour combines the functions of a local DNS server and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * AppleTalk. Bonjour allows applications to provide user-friendly printer
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and server browsing, among other things, over standard IP networks.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This behavior is a result of combining protocols such as multicast and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNS to add new functionality to the network (such as multicast DNS).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Bonjour gives applications easy access to services over local IP
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * networks without requiring the service or the application to support
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * an AppleTalk or a Netbeui stack, and without requiring a DNS server
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * for the local network.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* _DNS_SD_H contains the API version number for this header file
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The API version defined in this header file symbol allows for compile-time
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * checking, so that C code building with earlier versions of the header file
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * can avoid compile errors trying to use functions that aren't even defined
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * in those earlier versions. Similar checks may also be performed at run-time:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * => weak linking -- to avoid link failures if run with an earlier
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * version of the library that's missing some desired symbol, or
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * => DNSServiceGetProperty(DaemonVersion) -- to verify whether the running daemon
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ("system service" on Windows) meets some required minimum functionality level.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifndef _DNS_SD_H
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome#define _DNS_SD_H 6254102
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifdef __cplusplus
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soomeextern "C" {
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* Set to 1 if libdispatch is supported
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Note: May also be set by project and/or Makefile
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#ifndef _DNS_SD_LIBDISPATCH
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define _DNS_SD_LIBDISPATCH 0
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#endif /* ndef _DNS_SD_LIBDISPATCH */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* standard calling convention under Win32 is __stdcall */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define DNSSD_API __stdcall
4b22b9337f359bfd063322244f5336cc7c6ffcfars#else
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define DNSSD_API
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* stdint.h does not exist on FreeBSD 4.x; its types are defined in sys/types.h instead */
4b22b9337f359bfd063322244f5336cc7c6ffcfars#if defined(__FreeBSD__) && (__FreeBSD__ < 5)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include <sys/types.h>
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Likewise, on Sun, standard integer types are in sys/types.h */
4b22b9337f359bfd063322244f5336cc7c6ffcfars#elif defined(__sun__)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include <sys/types.h>
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* EFI does not have stdint.h, or anything else equivalent */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#elif defined(EFI32) || defined(EFI64) || defined(EFIX64)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#include "Tiano.h"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#if !defined(_STDINT_H_)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef UINT8 uint8_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef INT8 int8_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef UINT16 uint16_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef INT16 int16_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef UINT32 uint32_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef INT32 int32_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Windows has its own differences */
4b22b9337f359bfd063322244f5336cc7c6ffcfars#elif defined(_WIN32)
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include <windows.h>
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define _UNUSED
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifndef _MSL_STDINT_H
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef UINT8 uint8_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef INT8 int8_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef UINT16 uint16_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef INT16 int16_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef UINT32 uint32_t;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef INT32 int32_t;
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* All other Posix platforms use stdint.h */
4b22b9337f359bfd063322244f5336cc7c6ffcfars#else
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include <stdint.h>
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#endif
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#if _DNS_SD_LIBDISPATCH
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#include <dispatch/dispatch.h>
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceRef, DNSRecordRef
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Opaque internal data types.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: client is responsible for serializing access to these structures if
4b22b9337f359bfd063322244f5336cc7c6ffcfars * they are shared between concurrent threads.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct _DNSServiceRef_t *DNSServiceRef;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct _DNSRecordRef_t *DNSRecordRef;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soomestruct sockaddr;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*! @enum General flags
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Most DNS-SD API functions and callbacks include a DNSServiceFlags parameter.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * As a general rule, any given bit in the 32-bit flags field has a specific fixed meaning,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * regardless of the function or callback being used. For any given function or callback,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * typically only a subset of the possible flags are meaningful, and all others should be zero.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The discussion section for each API call describes which flags are valid for that call
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and callback. In some cases, for a particular call, it may be that no flags are currently
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * defined, in which case the DNSServiceFlags parameter exists purely to allow future expansion.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * In all cases, developers should expect that in future releases, it is possible that new flag
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * values will be defined, and write code with this in mind. For example, code that tests
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if (flags == kDNSServiceFlagsAdd) ...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * will fail if, in a future release, another bit in the 32-bit flags field is also set.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The reliable way to test whether a particular bit is set is not with an equality test,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * but with a bitwise mask:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if (flags & kDNSServiceFlagsAdd) ...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * With the exception of kDNSServiceFlagsValidate, each flag can be valid(be set)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * EITHER only as an input to one of the DNSService*() APIs OR only as an output
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (provide status) through any of the callbacks used. For example, kDNSServiceFlagsAdd
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * can be set only as an output in the callback, whereas the kDNSServiceFlagsIncludeP2P
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * can be set only as an input to the DNSService*() APIs. See comments on kDNSServiceFlagsValidate
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * defined in enum below.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome{
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsMoreComing = 0x1,
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* MoreComing indicates to a callback that at least one more result is
4b22b9337f359bfd063322244f5336cc7c6ffcfars * queued and will be delivered following immediately after this one.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When the MoreComing flag is set, applications should not immediately
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * update their UI, because this can result in a great deal of ugly flickering
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * on the screen, and can waste a great deal of CPU time repeatedly updating
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the screen with content that is then immediately erased, over and over.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Applications should wait until MoreComing is not set, and then
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * update their UI when no more changes are imminent.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * When MoreComing is not set, that doesn't mean there will be no more
4b22b9337f359bfd063322244f5336cc7c6ffcfars * answers EVER, just that there are no more answers immediately
4b22b9337f359bfd063322244f5336cc7c6ffcfars * available right now at this instant. If more answers become available
4b22b9337f359bfd063322244f5336cc7c6ffcfars * in the future they will be delivered as usual.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsAdd = 0x2,
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsDefault = 0x4,
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Flags for domain enumeration and browse/query reply callbacks.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * "Default" applies only to enumeration and is only valid in
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * conjunction with "Add". An enumeration callback with the "Add"
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flag NOT set indicates a "Remove", i.e. the domain is no longer
4b22b9337f359bfd063322244f5336cc7c6ffcfars * valid.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsNoAutoRename = 0x8,
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Flag for specifying renaming behavior on name conflict when registering
4b22b9337f359bfd063322244f5336cc7c6ffcfars * non-shared records. By default, name conflicts are automatically handled
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * by renaming the service. NoAutoRename overrides this behavior - with this
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flag set, name conflicts will result in a callback. The NoAutorename flag
4b22b9337f359bfd063322244f5336cc7c6ffcfars * is only valid if a name is explicitly specified when registering a service
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (i.e. the default name is not used.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsShared = 0x10,
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsUnique = 0x20,
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Flag for registering individual records on a connected
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRef. Shared indicates that there may be multiple records
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * with this name on the network (e.g. PTR records). Unique indicates that the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * record's name is to be unique on the network (e.g. SRV records).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsBrowseDomains = 0x40,
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsRegistrationDomains = 0x80,
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * BrowseDomains enumerates domains recommended for browsing, RegistrationDomains
4b22b9337f359bfd063322244f5336cc7c6ffcfars * enumerates domains recommended for registration.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsLongLivedQuery = 0x100,
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Flag for creating a long-lived unicast query for the DNSServiceQueryRecord call. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsAllowRemoteQuery = 0x200,
4b22b9337f359bfd063322244f5336cc7c6ffcfars /* Flag for creating a record for which we will answer remote queries
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (queries from hosts more than one hop away; hosts not directly connected to the local link).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceFlagsForceMulticast = 0x400,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* Flag for signifying that a query or registration should be performed exclusively via multicast
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNS, even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsForce = 0x800, // This flag is deprecated.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsKnownUnique = 0x800,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Client guarantees that record names are unique, so we can skip sending out initial
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * probe messages. Standard name conflict resolution is still done if a conflict is discovered.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Currently only valid for a DNSServiceRegister call.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsReturnIntermediates = 0x1000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* Flag for returning intermediate results.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For example, if a query results in an authoritative NXDomain (name does not exist)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * then that result is returned to the client. However the query is not implicitly
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * cancelled -- it remains active and if the answer subsequently changes
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (e.g. because a VPN tunnel is subsequently established) then that positive
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * result will still be returned to the client.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Similarly, if a query results in a CNAME record, then in addition to following
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the CNAME referral, the intermediate CNAME result is also returned to the client.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When this flag is not set, NXDomain errors are not returned, and CNAME records
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * are followed silently without informing the client of the intermediate steps.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (In earlier builds this flag was briefly calledkDNSServiceFlagsReturnCNAME)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsNonBrowsable = 0x2000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* A service registered with the NonBrowsable flag set can be resolved using
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceResolve(), but will not be discoverable using DNSServiceBrowse().
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This is for cases where the name is actually a GUID; it is found by other means;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * there is no end-user benefit to browsing to find a long list of opaque GUIDs.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Using the NonBrowsable flag creates SRV+TXT without the cost of also advertising
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * an associated PTR record.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsShareConnection = 0x4000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* For efficiency, clients that perform many concurrent operations may want to use a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * single Unix Domain Socket connection with the background daemon, instead of having a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * separate connection for each independent operation. To use this mode, clients first
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * call DNSServiceCreateConnection(&MainRef) to initialize the main DNSServiceRef.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For each subsequent operation that is to share that same connection, the client copies
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the MainRef, and then passes the address of that copy, setting the ShareConnection flag
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to tell the library that this DNSServiceRef is not a typical uninitialized DNSServiceRef;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * it's a copy of an existing DNSServiceRef whose connection information should be reused.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For example:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceErrorType error;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRef MainRef;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * error = DNSServiceCreateConnection(&MainRef);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if (error) ...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRef BrowseRef = MainRef; // Important: COPY the primary DNSServiceRef first...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * error = DNSServiceBrowse(&BrowseRef, kDNSServiceFlagsShareConnection, ...); // then use the copy
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if (error) ...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRefDeallocate(BrowseRef); // Terminate the browse operation
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRefDeallocate(MainRef); // Terminate the shared connection
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Also see Point 4.(Don't Double-Deallocate if the MainRef has been Deallocated) in Notes below:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Notes:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 1. Collective kDNSServiceFlagsMoreComing flag
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When callbacks are invoked using a shared DNSServiceRef, the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsMoreComing flag applies collectively to *all* active
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * operations sharing the same parent DNSServiceRef. If the MoreComing flag is
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * set it means that there are more results queued on this parent DNSServiceRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * but not necessarily more results for this particular callback function.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The implication of this for client programmers is that when a callback
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is invoked with the MoreComing flag set, the code should update its
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * internal data structures with the new result, and set a variable indicating
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * that its UI needs to be updated. Then, later when a callback is eventually
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * invoked with the MoreComing flag not set, the code should update *all*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * stale UI elements related to that shared parent DNSServiceRef that need
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * updating, not just the UI elements related to the particular callback
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * that happened to be the last one to be invoked.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 2. Canceling operations and kDNSServiceFlagsMoreComing
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Whenever you cancel any operation for which you had deferred UI updates
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * waiting because of a kDNSServiceFlagsMoreComing flag, you should perform
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * those deferred UI updates. This is because, after cancelling the operation,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * you can no longer wait for a callback *without* MoreComing set, to tell
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * you do perform your deferred UI updates (the operation has been canceled,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * so there will be no more callbacks). An implication of the collective
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsMoreComing flag for shared connections is that this
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * guideline applies more broadly -- any time you cancel an operation on
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * a shared connection, you should perform all deferred UI updates for all
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * operations sharing that connection. This is because the MoreComing flag
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * might have been referring to events coming for the operation you canceled,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * which will now not be coming because the operation has been canceled.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 3. Only share DNSServiceRef's created with DNSServiceCreateConnection
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Calling DNSServiceCreateConnection(&ref) creates a special shareable DNSServiceRef.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRef's created by other calls like DNSServiceBrowse() or DNSServiceResolve()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * cannot be shared by copying them and using kDNSServiceFlagsShareConnection.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 4. Don't Double-Deallocate if the MainRef has been Deallocated
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Calling DNSServiceRefDeallocate(ref) for a particular operation's DNSServiceRef terminates
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * just that operation. Calling DNSServiceRefDeallocate(ref) for the main shared DNSServiceRef
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (the parent DNSServiceRef, originally created by DNSServiceCreateConnection(&ref))
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * automatically terminates the shared connection and all operations that were still using it.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * After doing this, DO NOT then attempt to deallocate any remaining subordinate DNSServiceRef's.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The memory used by those subordinate DNSServiceRef's has already been freed, so any attempt
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to do a DNSServiceRefDeallocate (or any other operation) on them will result in accesses
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to freed memory, leading to crashes or other equally undesirable results.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 5. Thread Safety
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The dns_sd.h API does not presuppose any particular threading model, and consequently
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * does no locking of its own (which would require linking some specific threading library).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If client code calls API routines on the same DNSServiceRef concurrently
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * from multiple threads, it is the client's responsibility to use a mutext
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * lock or take similar appropriate precautions to serialize those calls.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsSuppressUnusable = 0x8000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful only in DNSServiceQueryRecord which suppresses unusable queries on the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * wire. If "hostname" is a wide-area unicast DNS hostname (i.e. not a ".local." name)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * but this host has no routable IPv6 address, then the call will not try to look up IPv6 addresses
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * for "hostname", since any addresses it found would be unlikely to be of any use anyway. Similarly,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if this host has no routable IPv4 address, the call will not try to look up IPv4 addresses for
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * "hostname".
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsTimeout = 0x10000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When kDNServiceFlagsTimeout is passed to DNSServiceQueryRecord or DNSServiceGetAddrInfo, the query is
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * stopped after a certain number of seconds have elapsed. The time at which the query will be stopped
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is determined by the system and cannot be configured by the user. The query will be stopped irrespective
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * of whether a response was given earlier or not. When the query is stopped, the callback will be called
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * with an error code of kDNSServiceErr_Timeout and a NULL sockaddr will be returned for DNSServiceGetAddrInfo
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and zero length rdata will be returned for DNSServiceQueryRecord.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsIncludeP2P = 0x20000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Include P2P interfaces when kDNSServiceInterfaceIndexAny is specified.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * By default, specifying kDNSServiceInterfaceIndexAny does not include P2P interfaces.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsWakeOnResolve = 0x40000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful only in DNSServiceResolve. When set, it tries to send a magic packet
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to wake up the client.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsBackgroundTrafficClass = 0x80000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful for Unicast DNS queries. When set, it uses the background traffic
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * class for packets that service the request.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsIncludeAWDL = 0x100000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Include AWDL interface when kDNSServiceInterfaceIndexAny is specified.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsValidate = 0x200000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful in DNSServiceGetAddrInfo and DNSServiceQueryRecord. This is the ONLY flag to be valid
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * as an input to the APIs and also an output through the callbacks in the APIs.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When this flag is passed to DNSServiceQueryRecord and DNSServiceGetAddrInfo to resolve unicast names,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the response will be validated using DNSSEC. The validation results are delivered using the flags field in
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the callback and kDNSServiceFlagsValidate is marked in the flags to indicate that DNSSEC status is also available.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When the callback is called to deliver the query results, the validation results may or may not be available.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If it is not delivered along with the results, the validation status is delivered when the validation completes.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When the validation results are delivered in the callback, it is indicated by marking the flags with
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsValidate and kDNSServiceFlagsAdd along with the DNSSEC status flags (described below) and a NULL
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sockaddr will be returned for DNSServiceGetAddrInfo and zero length rdata will be returned for DNSServiceQueryRecord.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSSEC validation results are for the whole RRSet and not just individual records delivered in the callback. When
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsAdd is not set in the flags, applications should implicitly assume that the DNSSEC status of the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * RRSet that has been delivered up until that point is not valid anymore, till another callback is called with
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsAdd and kDNSServiceFlagsValidate.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The following four flags indicate the status of the DNSSEC validation and marked in the flags field of the callback.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When any of the four flags is set, kDNSServiceFlagsValidate will also be set. To check the validation status, the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * other applicable output flags should be masked. See kDNSServiceOutputFlags below.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsSecure = 0x200010,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The response has been validated by verifying all the signaures in the response and was able to
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * build a successful authentication chain starting from a known trust anchor.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsInsecure = 0x200020,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * A chain of trust cannot be built starting from a known trust anchor to the response.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsBogus = 0x200040,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If the response cannot be verified to be secure due to expired signatures, missing signatures etc.,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * then the results are considered to be bogus.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsIndeterminate = 0x200080,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * There is no valid trust anchor that can be used to determine whether a response is secure or not.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsUnicastResponse = 0x400000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Request unicast response to query.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsValidateOptional = 0x800000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is identical to kDNSServiceFlagsValidate except for the case where the response
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * cannot be validated. If this flag is set in DNSServiceQueryRecord or DNSServiceGetAddrInfo,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the DNSSEC records will be requested for validation. If they cannot be received for some reason
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * during the validation (e.g., zone is not signed, zone is signed but cannot be traced back to
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * root, recursive server does not understand DNSSEC etc.), then this will fallback to the default
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * behavior where the validation will not be performed and no DNSSEC results will be provided.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If the zone is signed and there is a valid path to a known trust anchor configured in the system
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and the application requires DNSSEC validation irrespective of the DNSSEC awareness in the current
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * network, then this option MUST not be used. This is only intended to be used during the transition
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * period where the different nodes participating in the DNS resolution may not understand DNSSEC or
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * managed properly (e.g. missing DS record) but still want to be able to resolve DNS successfully.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsWakeOnlyService = 0x1000000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful only in DNSServiceRegister. When set, the service will not be registered
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * with sleep proxy server during sleep.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsThresholdOne = 0x2000000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsThresholdFinder = 0x4000000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsThresholdReached = kDNSServiceFlagsThresholdOne,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsThresholdOne is meaningful only in DNSServiceBrowse. When set,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the system will stop issuing browse queries on the network once the number
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * of answers returned is one or more. It will issue queries on the network
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * again if the number of answers drops to zero.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is for Apple internal use only. Third party developers
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * should not rely on this behavior being supported in any given software release.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsThresholdFinder is meaningful only in DNSServiceBrowse. When set,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the system will stop issuing browse queries on the network once the number
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * of answers has reached the threshold set for Finder.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * It will issue queries on the network again if the number of answers drops below
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * this threshold.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is for Apple internal use only. Third party developers
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * should not rely on this behavior being supported in any given software release.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When kDNSServiceFlagsThresholdReached is set in the client callback add or remove event,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * it indicates that the browse answer threshold has been reached and no
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * browse requests will be generated on the network until the number of answers falls
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * below the threshold value. Add and remove events can still occur based
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * on incoming Bonjour traffic observed by the system.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The set of services return to the client is not guaranteed to represent the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * entire set of services present on the network once the threshold has been reached.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Note, while kDNSServiceFlagsThresholdReached and kDNSServiceFlagsThresholdOne
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * have the same value, there isn't a conflict because kDNSServiceFlagsThresholdReached
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is only set in the callbacks and kDNSServiceFlagsThresholdOne is only set on
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * input to a DNSServiceBrowse call.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsDenyCellular = 0x8000000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful only for Unicast DNS queries. When set, the kernel will restrict
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNS resolutions on the cellular interface for that request.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceFlagsServiceIndex = 0x10000000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful only for DNSServiceGetAddrInfo() for Unicast DNS queries.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When set, DNSServiceGetAddrInfo() will interpret the "interfaceIndex" argument of the call
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * as the "serviceIndex".
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome kDNSServiceFlagsDenyExpensive = 0x20000000,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This flag is meaningful only for Unicast DNS queries. When set, the kernel will restrict
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNS resolutions on interfaces defined as expensive for that request.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome kDNSServiceFlagsPathEvaluationDone = 0x40000000
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome /*
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * This flag is meaningful for only Unicast DNS queries.
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * When set, it indicates that Network PathEvaluation has already been performed.
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome */
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome};
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceOutputFlags (kDNSServiceFlagsValidate | kDNSServiceFlagsValidateOptional | kDNSServiceFlagsMoreComing | kDNSServiceFlagsAdd | kDNSServiceFlagsDefault)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* All the output flags excluding the DNSSEC Status flags. Typically used to check DNSSEC Status */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* Possible protocol values */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soomeenum
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome{
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* for DNSServiceGetAddrInfo() */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceProtocol_IPv4 = 0x01,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceProtocol_IPv6 = 0x02,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* 0x04 and 0x08 reserved for future internetwork protocols */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* for DNSServiceNATPortMappingCreate() */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceProtocol_UDP = 0x10,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceProtocol_TCP = 0x20
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* 0x40 and 0x80 reserved for future transport protocols, e.g. SCTP [RFC 2960]
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * or DCCP [RFC 4340]. If future NAT gateways are created that support port
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * mappings for these protocols, new constants will be defined here.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome};
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The values for DNS Classes and Types are listed in RFC 1035, and are available
4b22b9337f359bfd063322244f5336cc7c6ffcfars * on every OS in its DNS header file. Unfortunately every OS does not have the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * same header file containing DNS Class and Type constants, and the names of
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the constants are not consistent. For example, BIND 8 uses "T_A",
4b22b9337f359bfd063322244f5336cc7c6ffcfars * BIND 9 uses "ns_t_a", Windows uses "DNS_TYPE_A", etc.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For this reason, these constants are also listed here, so that code using
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the DNS-SD programming APIs can use these constants, so that the same code
4b22b9337f359bfd063322244f5336cc7c6ffcfars * can compile on all our supported platforms.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome{
4b22b9337f359bfd063322244f5336cc7c6ffcfars kDNSServiceClass_IN = 1 /* Internet */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome};
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome{
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_A = 1, /* Host address. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NS = 2, /* Authoritative server. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MD = 3, /* Mail destination. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MF = 4, /* Mail forwarder. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_CNAME = 5, /* Canonical name. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_SOA = 6, /* Start of authority zone. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MB = 7, /* Mailbox domain name. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MG = 8, /* Mail group member. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MR = 9, /* Mail rename name. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NULL = 10, /* Null resource record. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_WKS = 11, /* Well known service. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_PTR = 12, /* Domain name pointer. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_HINFO = 13, /* Host information. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MINFO = 14, /* Mailbox information. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MX = 15, /* Mail routing information. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_TXT = 16, /* One or more text strings (NOT "zero or more..."). */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_RP = 17, /* Responsible person. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_AFSDB = 18, /* AFS cell database. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_X25 = 19, /* X_25 calling address. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_ISDN = 20, /* ISDN calling address. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_RT = 21, /* Router. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NSAP = 22, /* NSAP address. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated). */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_SIG = 24, /* Security signature. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_KEY = 25, /* Security key. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_PX = 26, /* X.400 mail mapping. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_GPOS = 27, /* Geographical position (withdrawn). */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_AAAA = 28, /* IPv6 Address. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_LOC = 29, /* Location Information. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NXT = 30, /* Next domain (security). */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_EID = 31, /* Endpoint identifier. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NIMLOC = 32, /* Nimrod Locator. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_SRV = 33, /* Server Selection. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_ATMA = 34, /* ATM Address */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NAPTR = 35, /* Naming Authority PoinTeR */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_KX = 36, /* Key Exchange */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_CERT = 37, /* Certification record */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_A6 = 38, /* IPv6 Address (deprecated) */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_DNAME = 39, /* Non-terminal DNAME (for IPv6) */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_SINK = 40, /* Kitchen sink (experimental) */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_OPT = 41, /* EDNS0 option (meta-RR) */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_APL = 42, /* Address Prefix List */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_DS = 43, /* Delegation Signer */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_SSHFP = 44, /* SSH Key Fingerprint */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_IPSECKEY = 45, /* IPSECKEY */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_RRSIG = 46, /* RRSIG */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NSEC = 47, /* Denial of Existence */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_DNSKEY = 48, /* DNSKEY */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_DHCID = 49, /* DHCP Client Identifier */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NSEC3 = 50, /* Hashed Authenticated Denial of Existence */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_NSEC3PARAM = 51, /* Hashed Authenticated Denial of Existence */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_HIP = 55, /* Host Identity Protocol */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_SPF = 99, /* Sender Policy Framework for E-Mail */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_UINFO = 100, /* IANA-Reserved */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_UID = 101, /* IANA-Reserved */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_GID = 102, /* IANA-Reserved */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_UNSPEC = 103, /* IANA-Reserved */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_TKEY = 249, /* Transaction key */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_TSIG = 250, /* Transaction signature. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_IXFR = 251, /* Incremental zone transfer. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_AXFR = 252, /* Transfer zone of authority. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MAILB = 253, /* Transfer mailbox records. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_MAILA = 254, /* Transfer mail agent records. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceType_ANY = 255 /* Wildcard match. */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome};
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* possible error code values */
4b22b9337f359bfd063322244f5336cc7c6ffcfarsenum
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome{
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NoError = 0,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Unknown = -65537, /* 0xFFFE FFFF */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NoSuchName = -65538,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NoMemory = -65539,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadParam = -65540,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadReference = -65541,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadState = -65542,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadFlags = -65543,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Unsupported = -65544,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NotInitialized = -65545,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_AlreadyRegistered = -65547,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NameConflict = -65548,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Invalid = -65549,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Firewall = -65550,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Incompatible = -65551, /* client library incompatible with daemon */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadInterfaceIndex = -65552,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Refused = -65553,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NoSuchRecord = -65554,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NoAuth = -65555,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NoSuchKey = -65556,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NATTraversal = -65557,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_DoubleNAT = -65558,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadTime = -65559, /* Codes up to here existed in Tiger */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadSig = -65560,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_BadKey = -65561,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Transient = -65562,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_ServiceNotRunning = -65563, /* Background daemon not running */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NATPortMappingUnsupported = -65564, /* NAT doesn't support PCP, NAT-PMP or UPnP */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NATPortMappingDisabled = -65565, /* NAT supports PCP, NAT-PMP or UPnP, but it's disabled by the administrator */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_NoRouter = -65566, /* No router currently configured (probably no network connectivity) */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_PollingMode = -65567,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome kDNSServiceErr_Timeout = -65568
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome /* mDNS Error codes are in the range
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * FFFE FF00 (-65792) to FFFE FFFF (-65537) */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome};
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Maximum length, in bytes, of a service name represented as a */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* literal C-String, including the terminating NULL at the end. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kDNSServiceMaxServiceName 64
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Maximum length, in bytes, of a domain name represented as an *escaped* C-String */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* including the final trailing dot, and the C-String terminating NULL at the end. */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceMaxDomainName 1009
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Notes on DNS Name Escaping
4b22b9337f359bfd063322244f5336cc7c6ffcfars * -- or --
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * "Why is kDNSServiceMaxDomainName 1009, when the maximum legal domain name is 256 bytes?"
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * All strings used in the DNS-SD APIs are UTF-8 strings. Apart from the exceptions noted below,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the APIs expect the strings to be properly escaped, using the conventional DNS escaping rules:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * '\\' represents a single literal '\' in the name
4b22b9337f359bfd063322244f5336cc7c6ffcfars * '\.' represents a single literal '.' in the name
4b22b9337f359bfd063322244f5336cc7c6ffcfars * '\ddd', where ddd is a three-digit decimal value from 000 to 255,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * represents a single literal byte with that value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * A bare unescaped '.' is a label separator, marking a boundary between domain and subdomain.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The exceptions, that do not use escaping, are the routines where the full
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNS name of a resource is broken, for convenience, into servicename/regtype/domain.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * In these routines, the "servicename" is NOT escaped. It does not need to be, since
4b22b9337f359bfd063322244f5336cc7c6ffcfars * it is, by definition, just a single literal string. Any characters in that string
4b22b9337f359bfd063322244f5336cc7c6ffcfars * represent exactly what they are. The "regtype" portion is, technically speaking,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * escaped, but since legal regtypes are only allowed to contain letters, digits,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and hyphens, there is nothing to escape, so the issue is moot. The "domain"
4b22b9337f359bfd063322244f5336cc7c6ffcfars * portion is also escaped, though most domains in use on the public Internet
4b22b9337f359bfd063322244f5336cc7c6ffcfars * today, like regtypes, don't contain any characters that need to be escaped.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * As DNS-SD becomes more popular, rich-text domains for service discovery will
4b22b9337f359bfd063322244f5336cc7c6ffcfars * become common, so software should be written to cope with domains with escaping.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The servicename may be up to 63 bytes of UTF-8 text (not counting the C-String
4b22b9337f359bfd063322244f5336cc7c6ffcfars * terminating NULL at the end). The regtype is of the form _service._tcp or
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * _service._udp, where the "service" part is 1-15 characters, which may be
4b22b9337f359bfd063322244f5336cc7c6ffcfars * letters, digits, or hyphens. The domain part of the three-part name may be
4b22b9337f359bfd063322244f5336cc7c6ffcfars * any legal domain, providing that the resulting servicename+regtype+domain
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * name does not exceed 256 bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For most software, these issues are transparent. When browsing, the discovered
4b22b9337f359bfd063322244f5336cc7c6ffcfars * servicenames should simply be displayed as-is. When resolving, the discovered
4b22b9337f359bfd063322244f5336cc7c6ffcfars * servicename/regtype/domain are simply passed unchanged to DNSServiceResolve().
4b22b9337f359bfd063322244f5336cc7c6ffcfars * When a DNSServiceResolve() succeeds, the returned fullname is already in
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the correct format to pass to standard system DNS APIs such as res_query().
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For converting from servicename/regtype/domain to a single properly-escaped
4b22b9337f359bfd063322244f5336cc7c6ffcfars * full DNS name, the helper function DNSServiceConstructFullName() is provided.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The following (highly contrived) example illustrates the escaping process.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Suppose you have an service called "Dr. Smith\Dr. Johnson", of type "_ftp._tcp"
4b22b9337f359bfd063322244f5336cc7c6ffcfars * in subdomain "4th. Floor" of subdomain "Building 2" of domain "apple.com."
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The full (escaped) DNS name of this service's SRV record would be:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Dr\.\032Smith\\Dr\.\032Johnson._ftp._tcp.4th\.\032Floor.Building\0322.apple.com.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Constants for specifying an interface index
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Specific interface indexes are identified via a 32-bit unsigned integer returned
4b22b9337f359bfd063322244f5336cc7c6ffcfars * by the if_nametoindex() family of calls.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If the client passes 0 for interface index, that means "do the right thing",
4b22b9337f359bfd063322244f5336cc7c6ffcfars * which (at present) means, "if the name is in an mDNS local multicast domain
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast
4b22b9337f359bfd063322244f5336cc7c6ffcfars * on all applicable interfaces, otherwise send via unicast to the appropriate
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNS server." Normally, most clients will use 0 for interface index to
4b22b9337f359bfd063322244f5336cc7c6ffcfars * automatically get the default sensible behaviour.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * If the client passes a positive interface index, then that indicates to do the
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * operation only on that one specified interface.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If the client passes kDNSServiceInterfaceIndexLocalOnly when registering
4b22b9337f359bfd063322244f5336cc7c6ffcfars * a service, then that service will be found *only* by other local clients
4b22b9337f359bfd063322244f5336cc7c6ffcfars * on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly
4b22b9337f359bfd063322244f5336cc7c6ffcfars * or kDNSServiceInterfaceIndexAny.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If a client has a 'private' service, accessible only to other processes
4b22b9337f359bfd063322244f5336cc7c6ffcfars * running on the same machine, this allows the client to advertise that service
4b22b9337f359bfd063322244f5336cc7c6ffcfars * in a way such that it does not inadvertently appear in service lists on
4b22b9337f359bfd063322244f5336cc7c6ffcfars * all the other machines on the network.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If the client passes kDNSServiceInterfaceIndexLocalOnly when browsing
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then it will find *all* records registered on that same local machine.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Clients explicitly wishing to discover *only* LocalOnly services can
4b22b9337f359bfd063322244f5336cc7c6ffcfars * accomplish this by inspecting the interfaceIndex of each service reported
4b22b9337f359bfd063322244f5336cc7c6ffcfars * to their DNSServiceBrowseReply() callback function, and discarding those
4b22b9337f359bfd063322244f5336cc7c6ffcfars * where the interface index is not kDNSServiceInterfaceIndexLocalOnly.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceInterfaceIndexP2P is meaningful only in Browse, QueryRecord, Register,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and Resolve operations. It should not be used in other DNSService APIs.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceBrowse or
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceQueryRecord, it restricts the operation to P2P.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceRegister, it is
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * mapped internally to kDNSServiceInterfaceIndexAny with the kDNSServiceFlagsIncludeP2P
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * set.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * - If kDNSServiceInterfaceIndexP2P is passed to DNSServiceResolve, it is
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * mapped internally to kDNSServiceInterfaceIndexAny with the kDNSServiceFlagsIncludeP2P
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * set, because resolving a P2P service may create and/or enable an interface whose
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * index is not known a priori. The resolve callback will indicate the index of the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interface via which the service can be accessed.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If applications pass kDNSServiceInterfaceIndexAny to DNSServiceBrowse
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * or DNSServiceQueryRecord, they must set the kDNSServiceFlagsIncludeP2P flag
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to include P2P. In this case, if a service instance or the record being queried
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is found over P2P, the resulting ADD event will indicate kDNSServiceInterfaceIndexP2P
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * as the interface index.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define kDNSServiceInterfaceIndexAny 0
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceInterfaceIndexLocalOnly ((uint32_t)-1)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceInterfaceIndexUnicast ((uint32_t)-2)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceInterfaceIndexP2P ((uint32_t)-3)
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef uint32_t DNSServiceFlags;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef uint32_t DNSServiceProtocol;
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef int32_t DNSServiceErrorType;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Version checking
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceGetProperty() Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * property: The requested property.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Currently the only property defined is kDNSServiceProperty_DaemonVersion.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * result: Place to store result.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For retrieving DaemonVersion, this should be the address of a uint32_t.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * size: Pointer to uint32_t containing size of the result location.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For retrieving DaemonVersion, this should be sizeof(uint32_t).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * On return the uint32_t is updated to the size of the data returned.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For DaemonVersion, the returned size is always sizeof(uint32_t), but
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * future properties could be defined which return variable-sized results.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success, or kDNSServiceErr_ServiceNotRunning
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if the daemon (or "system service" on Windows) is not running.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceGetProperty
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char *property, /* Requested property (i.e. kDNSServiceProperty_DaemonVersion) */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *result, /* Pointer to place to store result */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t *size /* size of result location */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When requesting kDNSServiceProperty_DaemonVersion, the result pointer must point
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to a 32-bit unsigned integer, and the size parameter must be set to sizeof(uint32_t).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * On return, the 32-bit unsigned integer contains the API version number
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For example, Mac OS X 10.4.9 has API version 1080400.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This allows applications to do simple greater-than and less-than comparisons:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * e.g. an application that requires at least API version 1080400 can check:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if (version >= 1080400) ...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Example usage:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * uint32_t version;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * uint32_t size = sizeof(version);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if (!err) printf("DNS_SD API version is %d.%d\n", version / 10000, version / 100 % 100);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceProperty_DaemonVersion "DaemonVersion"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome// Map the source port of the local UDP socket that was opened for sending the DNS query
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome// to the process ID of the application that triggered the DNS resolution.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome//
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceGetPID() Parameters:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * srcport: Source port (in network byte order) of the UDP socket that was created by
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the daemon to send the DNS query on the wire.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * pid: Process ID of the application that started the name resolution which triggered
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the daemon to send the query on the wire. The value can be -1 if the srcport
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * cannot be mapped.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success, or kDNSServiceErr_ServiceNotRunning
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if the daemon is not running. The value of the pid is undefined if the return
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * value has error.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceGetPID
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t srcport,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome int32_t *pid
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceRefSockFD()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Access underlying Unix domain socket for an initialized DNSServiceRef.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The DNS Service Discovery implementation uses this socket to communicate between the client and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the daemon. The application MUST NOT directly read from or write to this socket.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Access to the socket is provided so that it can be used as a kqueue event source, a CFRunLoop
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * event source, in a select() loop, etc. When the underlying event management subsystem (kqueue/
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * select/CFRunLoop etc.) indicates to the client that data is available for reading on the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * socket, the client should call DNSServiceProcessResult(), which will extract the daemon's
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * reply from the socket, and pass it to the appropriate application callback. By using a run
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * loop or select(), results from the daemon can be processed asynchronously. Alternatively,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * a client can choose to fork a thread and have it loop calling "DNSServiceProcessResult(ref);"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If DNSServiceProcessResult() is called when no data is available for reading on the socket, it
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * will block until data does become available, and then process the data and return to the caller.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The application is reponsible for checking the return value of DNSServiceProcessResult() to determine
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if the socket is valid and if it should continue to process data on the socket.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When data arrives on the socket, the client is responsible for calling DNSServiceProcessResult(ref)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * in a timely fashion -- if the client allows a large backlog of data to build up the daemon
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * may terminate the connection.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: The DNSServiceRef's underlying socket descriptor, or -1 on
4b22b9337f359bfd063322244f5336cc7c6ffcfars * error.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsint DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdRef);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceProcessResult()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Read a reply from the daemon, calling the appropriate application callback. This call will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * block until the daemon's response is received. Use DNSServiceRefSockFD() in
4b22b9337f359bfd063322244f5336cc7c6ffcfars * conjunction with a run loop or select() to determine the presence of a response from the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * server before calling this function to process the reply without blocking. Call this function
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * at any point if it is acceptable to block until the daemon's response arrives. Note that the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is
4b22b9337f359bfd063322244f5336cc7c6ffcfars * a reply from the daemon - the daemon may terminate its connection with a client that does not
4b22b9337f359bfd063322244f5336cc7c6ffcfars * process the daemon's responses.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: A DNSServiceRef initialized by any of the DNSService calls
4b22b9337f359bfd063322244f5336cc7c6ffcfars * that take a callback parameter.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
4b22b9337f359bfd063322244f5336cc7c6ffcfars * an error code indicating the specific failure that occurred.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdRef);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceRefDeallocate()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Terminate a connection with the daemon and free memory associated with the DNSServiceRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Any services or records registered with this DNSServiceRef will be deregistered. Any
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Browse, Resolve, or Query operations called with this reference will be terminated.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: If the reference's underlying socket is used in a run loop or select() call, it should
4b22b9337f359bfd063322244f5336cc7c6ffcfars * be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's
4b22b9337f359bfd063322244f5336cc7c6ffcfars * socket.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs
4b22b9337f359bfd063322244f5336cc7c6ffcfars * created via this reference will be invalidated by this call - the resource records are
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * if the reference was initialized with DNSServiceRegister, and an extra resource record was
4b22b9337f359bfd063322244f5336cc7c6ffcfars * added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call
4b22b9337f359bfd063322244f5336cc7c6ffcfars * is invalidated when this function is called - the DNSRecordRef may not be used in subsequent
4b22b9337f359bfd063322244f5336cc7c6ffcfars * functions.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Note: This call is to be used only with the DNSServiceRef defined by this API.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsvoid DNSSD_API DNSServiceRefDeallocate(DNSServiceRef sdRef);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Domain Enumeration
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceEnumerateDomains()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Asynchronously enumerate domains available for browsing and registration.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
4b22b9337f359bfd063322244f5336cc7c6ffcfars * are to be found.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note that the names returned are (like all of DNS-SD) UTF-8 strings,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and are escaped using standard DNS escaping rules.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (See "Notes on DNS Name Escaping" earlier in this file for more details.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * A graphical browser displaying a hierarchical tree-structured view should cut
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the names at the bare dots to yield individual labels, then de-escape each
4b22b9337f359bfd063322244f5336cc7c6ffcfars * label according to the escaping rules, and then display the resulting UTF-8 text.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceDomainEnumReply Callback Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Possible values are:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * kDNSServiceFlagsMoreComing
4b22b9337f359bfd063322244f5336cc7c6ffcfars * kDNSServiceFlagsAdd
4b22b9337f359bfd063322244f5336cc7c6ffcfars * kDNSServiceFlagsDefault
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interface is determined via the if_nametoindex() family of calls.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise indicates
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the failure that occurred (other parameters are undefined if errorCode is nonzero).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * replyDomain: The name of the domain.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: The context pointer passed to DNSServiceEnumerateDomains.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void (DNSSD_API *DNSServiceDomainEnumReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *replyDomain,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceEnumerateDomains() Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and the enumeration operation will run indefinitely until the client
4b22b9337f359bfd063322244f5336cc7c6ffcfars * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Possible values are:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * kDNSServiceFlagsBrowseDomains to enumerate domains recommended for browsing.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * kDNSServiceFlagsRegistrationDomains to enumerate domains recommended
4b22b9337f359bfd063322244f5336cc7c6ffcfars * for registration.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * family of calls.) Most applications will pass 0 to enumerate domains on
4b22b9337f359bfd063322244f5336cc7c6ffcfars * all interfaces. See "Constants for specifying an interface index" for more details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * callBack: The function to be called when a domain is found or the call asynchronously
4b22b9337f359bfd063322244f5336cc7c6ffcfars * fails.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: An application context pointer which is passed to the callback function
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (may be NULL).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errors are delivered to the callback), otherwise returns an error code indicating
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the error that occurred (the callback is not invoked and the DNSServiceRef
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is not initialized).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceDomainEnumReply callBack,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Service Registration
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Register a service that is discovered via Browse() and Resolve() calls.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRegisterReply() Callback Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: The DNSServiceRef initialized by DNSServiceRegister().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: When a name is successfully registered, the callback will be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * invoked with the kDNSServiceFlagsAdd flag set. When Wide-Area
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNS-SD is in use, it is possible for a single service to get
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * more than one success callback (e.g. one in the "local" multicast
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNS domain, and another in a wide-area unicast DNS domain).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If a successfully-registered name later suffers a name conflict
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * or similar problem and has to be deregistered, the callback will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * be invoked with the kDNSServiceFlagsAdd flag not set. The callback
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is *not* invoked in the case where the caller explicitly terminates
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the service registration by calling DNSServiceRefDeallocate(ref);
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
4b22b9337f359bfd063322244f5336cc7c6ffcfars * indicate the failure that occurred (including name conflicts,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * if the kDNSServiceFlagsNoAutoRename flag was used when registering.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Other parameters are undefined if errorCode is nonzero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * name: The service name registered (if the application did not specify a name in
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRegister(), this indicates what name was automatically chosen).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * regtype: The type of service registered, as it was passed to the callout.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * domain: The domain on which the service was registered (if the application did not
4b22b9337f359bfd063322244f5336cc7c6ffcfars * specify a domain in DNSServiceRegister(), this indicates the default domain
4b22b9337f359bfd063322244f5336cc7c6ffcfars * on which the service was registered).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: The context pointer that was passed to the callout.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void (DNSSD_API *DNSServiceRegisterReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *name,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *regtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *domain,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceRegister() Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and the registration will remain active indefinitely until the client
4b22b9337f359bfd063322244f5336cc7c6ffcfars * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaceIndex: If non-zero, specifies the interface on which to register the service
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * family of calls.) Most applications will pass 0 to register on all
4b22b9337f359bfd063322244f5336cc7c6ffcfars * available interfaces. See "Constants for specifying an interface index" for more details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Indicates the renaming behavior on name conflict (most applications
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * will pass 0). See flag definitions above for details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * name: If non-NULL, specifies the service name to be registered.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Most applications will not specify a name, in which case the computer
4b22b9337f359bfd063322244f5336cc7c6ffcfars * name is used (this name is communicated to the client via the callback).
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If a name is specified, it must be 1-63 bytes of UTF-8 text.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If the name is longer than 63 bytes it will be automatically truncated
4b22b9337f359bfd063322244f5336cc7c6ffcfars * to a legal length, unless the NoAutoRename flag is set,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * in which case kDNSServiceErr_BadParam will be returned.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * regtype: The service type followed by the protocol, separated by a dot
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (e.g. "_ftp._tcp"). The service type must be an underscore, followed
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * by 1-15 characters, which may be letters, digits, or hyphens.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The transport protocol must be "_tcp" or "_udp". New service types
4b22b9337f359bfd063322244f5336cc7c6ffcfars * should be registered at <http://www.dns-sd.org/ServiceTypes.html>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Additional subtypes of the primary service type (where a service
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * type has defined subtypes) follow the primary service type in a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * comma-separated list, with no additional spaces, e.g.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * "_primarytype._tcp,_subtype1,_subtype2,_subtype3"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Subtypes provide a mechanism for filtered browsing: A client browsing
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * for "_primarytype._tcp" will discover all instances of this type;
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * a client browsing for "_primarytype._tcp,_subtype2" will discover only
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * those instances that were registered with "_subtype2" in their list of
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * registered subtypes.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The subtype mechanism can be illustrated with some examples using the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * dns-sd command-line tool:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -R Simple _test._tcp "" 1001 &
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -R Better _test._tcp,HasFeatureA "" 1002 &
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -R Best _test._tcp,HasFeatureA,HasFeatureB "" 1003 &
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Now:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -B _test._tcp # will find all three services
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -B _test._tcp,HasFeatureA # finds "Better" and "Best"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -B _test._tcp,HasFeatureB # finds only "Best"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Subtype labels may be up to 63 bytes long, and may contain any eight-
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * bit byte values, including zero bytes. However, due to the nature of
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * using a C-string-based API, conventional DNS escaping must be used for
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * dots ('.'), commas (','), backslashes ('\') and zero bytes, as shown below:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -R Test '_test._tcp,s\.one,s\,two,s\\three,s\000four' local 123
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * When a service is registered, all the clients browsing for the registered
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * type ("regtype") will discover it. If the discovery should be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * restricted to a smaller set of well known peers, the service can be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * registered with additional data (group identifier) that is known
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * only to a smaller set of peers. The group identifier should follow primary
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * service type using a colon (":") as a delimeter. If subtypes are also present,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * it should be given before the subtype as shown below.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -R _test1 _http._tcp:mygroup1 local 1001
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -R _test2 _http._tcp:mygroup2 local 1001
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -R _test3 _http._tcp:mygroup3,HasFeatureA local 1001
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Now:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -B _http._tcp:"mygroup1" # will discover only test1
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -B _http._tcp:"mygroup2" # will discover only test2
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * % dns-sd -B _http._tcp:"mygroup3",HasFeatureA # will discover only test3
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * By specifying the group information, only the members of that group are
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * discovered.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The group identifier itself is not sent in clear. Only a hash of the group
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * identifier is sent and the clients discover them anonymously. The group identifier
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * may be up to 256 bytes long and may contain any eight bit values except comma which
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * should be escaped.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * domain: If non-NULL, specifies the domain on which to advertise the service.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Most applications will not specify a domain, instead automatically
4b22b9337f359bfd063322244f5336cc7c6ffcfars * registering in the default domain(s).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * host: If non-NULL, specifies the SRV target host name. Most applications
4b22b9337f359bfd063322244f5336cc7c6ffcfars * will not specify a host, instead automatically using the machine's
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * default host name(s). Note that specifying a non-NULL host does NOT
4b22b9337f359bfd063322244f5336cc7c6ffcfars * create an address record for that host - the application is responsible
4b22b9337f359bfd063322244f5336cc7c6ffcfars * for ensuring that the appropriate address record exists, or creating it
4b22b9337f359bfd063322244f5336cc7c6ffcfars * via DNSServiceRegisterRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * port: The port, in network byte order, on which the service accepts connections.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered
4b22b9337f359bfd063322244f5336cc7c6ffcfars * by browsing, but will cause a name conflict if another client tries to
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * register that same name). Most clients will not use placeholder services.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * txtLen: The length of the txtRecord, in bytes. Must be zero if the txtRecord is NULL.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: The TXT record rdata. A non-NULL txtRecord MUST be a properly formatted DNS
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXT record, i.e. <length byte> <data> <length byte> <data> ...
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Passing NULL for the txtRecord is allowed as a synonym for txtLen=1, txtRecord="",
4b22b9337f359bfd063322244f5336cc7c6ffcfars * i.e. it creates a TXT record of length one containing a single empty string.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * RFC 1035 doesn't allow a TXT record to contain *zero* strings, so a single empty
4b22b9337f359bfd063322244f5336cc7c6ffcfars * string is the smallest legal DNS TXT record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * As with the other parameters, the DNSServiceRegister call copies the txtRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfars * data; e.g. if you allocated the storage for the txtRecord parameter with malloc()
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then you can safely free that memory right after the DNSServiceRegister call returns.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * callBack: The function to be called when the registration completes or asynchronously
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * fails. The client MAY pass NULL for the callback - The client will NOT be notified
4b22b9337f359bfd063322244f5336cc7c6ffcfars * of the default values picked on its behalf, and the client will NOT be notified of any
4b22b9337f359bfd063322244f5336cc7c6ffcfars * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The client may still deregister the service at any time via DNSServiceRefDeallocate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: An application context pointer which is passed to the callback function
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (may be NULL).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errors are delivered to the callback), otherwise returns an error code indicating
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the error that occurred (the callback is never invoked and the DNSServiceRef
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is not initialized).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceRegister
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *name, /* may be NULL */
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *regtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *domain, /* may be NULL */
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *host, /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t port, /* In network byte order */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t txtLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *txtRecord, /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRegisterReply callBack, /* may be NULL */
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceAddRecord()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Add a record to a registered service. The name of the record will be the same as the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * registered service's name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The record can later be updated or deregistered by passing the RecordRef initialized
4b22b9337f359bfd063322244f5336cc7c6ffcfars * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note that the DNSServiceAddRecord/UpdateRecord/RemoveRecord are *NOT* thread-safe
4b22b9337f359bfd063322244f5336cc7c6ffcfars * with respect to a single DNSServiceRef. If you plan to have multiple threads
4b22b9337f359bfd063322244f5336cc7c6ffcfars * in your program simultaneously add, update, or remove records from the same
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRef, then it's the caller's responsibility to use a mutext lock
4b22b9337f359bfd063322244f5336cc7c6ffcfars * or take similar appropriate precautions to serialize those calls.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Parameters;
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: A DNSServiceRef initialized by DNSServiceRegister().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
4b22b9337f359bfd063322244f5336cc7c6ffcfars * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If the above DNSServiceRef is passed to DNSServiceRefDeallocate(), RecordRef is also
4b22b9337f359bfd063322244f5336cc7c6ffcfars * invalidated and may not be used further.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Currently ignored, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rrtype: The type of the record (e.g. kDNSServiceType_TXT, kDNSServiceType_SRV, etc)
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdlen: The length, in bytes, of the rdata.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdata: The raw rdata to be contained in the added resource record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ttl: The time to live of the resource record, in seconds.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Most clients should pass 0 to indicate that the system should
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * select a sensible default value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
4b22b9337f359bfd063322244f5336cc7c6ffcfars * error code indicating the error that occurred (the RecordRef is not initialized).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceAddRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSRecordRef *RecordRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrtype,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rdlen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *rdata,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t ttl
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceUpdateRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Update a registered resource record. The record must either be:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * - The primary txt record of a service registered via DNSServiceRegister()
4b22b9337f359bfd063322244f5336cc7c6ffcfars * - A record added to a registered service via DNSServiceAddRecord()
4b22b9337f359bfd063322244f5336cc7c6ffcfars * - An individual record registered by DNSServiceRegisterRecord()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: A DNSServiceRef that was initialized by DNSServiceRegister()
4b22b9337f359bfd063322244f5336cc7c6ffcfars * or DNSServiceCreateConnection().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * RecordRef: A DNSRecordRef initialized by DNSServiceAddRecord, or NULL to update the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * service's primary txt record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Currently ignored, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdlen: The length, in bytes, of the new rdata.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdata: The new rdata to be contained in the updated resource record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * ttl: The time to live of the updated resource record, in seconds.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Most clients should pass 0 to indicate that the system should
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * select a sensible default value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
4b22b9337f359bfd063322244f5336cc7c6ffcfars * error code indicating the error that occurred.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceUpdateRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSRecordRef RecordRef, /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rdlen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *rdata,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t ttl
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceRemoveRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Remove a record previously added to a service record set via DNSServiceAddRecord(), or deregister
4b22b9337f359bfd063322244f5336cc7c6ffcfars * an record registered individually via DNSServiceRegisterRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: A DNSServiceRef initialized by DNSServiceRegister() (if the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * record being removed was registered via DNSServiceAddRecord()) or by
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceCreateConnection() (if the record being removed was registered via
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRegisterRecord()).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * recordRef: A DNSRecordRef initialized by a successful call to DNSServiceAddRecord()
4b22b9337f359bfd063322244f5336cc7c6ffcfars * or DNSServiceRegisterRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Currently ignored, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
4b22b9337f359bfd063322244f5336cc7c6ffcfars * error code indicating the error that occurred.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceRemoveRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSRecordRef RecordRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Service Discovery
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Browse for instances of a service.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceBrowseReply() Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: The DNSServiceRef initialized by DNSServiceBrowse().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See flag definitions for details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: The interface on which the service is advertised. This index should
4b22b9337f359bfd063322244f5336cc7c6ffcfars * be passed to DNSServiceResolve() when resolving the service.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * indicate the failure that occurred. Other parameters are undefined if
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the errorCode is nonzero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * serviceName: The discovered service name. This name should be displayed to the user,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and stored for subsequent use in the DNSServiceResolve() call.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * regtype: The service type, which is usually (but not always) the same as was passed
4b22b9337f359bfd063322244f5336cc7c6ffcfars * to DNSServiceBrowse(). One case where the discovered service type may
4b22b9337f359bfd063322244f5336cc7c6ffcfars * not be the same as the requested service type is when using subtypes:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The client may want to browse for only those ftp servers that allow
4b22b9337f359bfd063322244f5336cc7c6ffcfars * anonymous connections. The client will pass the string "_ftp._tcp,_anon"
4b22b9337f359bfd063322244f5336cc7c6ffcfars * to DNSServiceBrowse(), but the type of the service that's discovered
4b22b9337f359bfd063322244f5336cc7c6ffcfars * is simply "_ftp._tcp". The regtype for each discovered service instance
4b22b9337f359bfd063322244f5336cc7c6ffcfars * should be stored along with the name, so that it can be passed to
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceResolve() when the service is later resolved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * domain: The domain of the discovered service instance. This may or may not be the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * same as the domain that was passed to DNSServiceBrowse(). The domain for each
4b22b9337f359bfd063322244f5336cc7c6ffcfars * discovered service instance should be stored along with the name, so that
4b22b9337f359bfd063322244f5336cc7c6ffcfars * it can be passed to DNSServiceResolve() when the service is later resolved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: The context pointer that was passed to the callout.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void (DNSSD_API *DNSServiceBrowseReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *serviceName,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *regtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *replyDomain,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceBrowse() Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and the browse operation will run indefinitely until the client
4b22b9337f359bfd063322244f5336cc7c6ffcfars * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Currently ignored, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaceIndex: If non-zero, specifies the interface on which to browse for services
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * family of calls.) Most applications will pass 0 to browse on all available
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaces. See "Constants for specifying an interface index" for more details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * regtype: The service type being browsed for followed by the protocol, separated by a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * A client may optionally specify a single subtype to perform filtered browsing:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * e.g. browsing for "_primarytype._tcp,_subtype" will discover only those
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * instances of "_primarytype._tcp" that were registered specifying "_subtype"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * in their list of registered subtypes. Additionally, a group identifier may
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * also be specified before the subtype e.g., _primarytype._tcp:GroupID, which
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * will discover only the members that register the service with GroupID. See
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRegister for more details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * domain: If non-NULL, specifies the domain on which to browse for services.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Most applications will not specify a domain, instead browsing on the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * default domain(s).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * callBack: The function to be called when an instance of the service being browsed for
4b22b9337f359bfd063322244f5336cc7c6ffcfars * is found, or if the call asynchronously fails.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: An application context pointer which is passed to the callback function
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (may be NULL).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errors are delivered to the callback), otherwise returns an error code indicating
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the error that occurred (the callback is not invoked and the DNSServiceRef
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is not initialized).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceBrowse
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *regtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *domain, /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceBrowseReply callBack,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceResolve()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Resolve a service name discovered via DNSServiceBrowse() to a target host name, port number, and
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txt record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: Applications should NOT use DNSServiceResolve() solely for txt record monitoring - use
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceQueryRecord() instead, as it is more efficient for this task.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRefDeallocate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: DNSServiceResolve() behaves correctly for typical services that have a single SRV record
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and a single TXT record. To resolve non-standard services with multiple SRV or TXT records,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceQueryRecord() should be used.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceResolveReply Callback Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: The DNSServiceRef initialized by DNSServiceResolve().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: Possible values: kDNSServiceFlagsMoreComing
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaceIndex: The interface on which the service was resolved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * indicate the failure that occurred. Other parameters are undefined if
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the errorCode is nonzero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (This name is escaped following standard DNS rules, making it suitable for
4b22b9337f359bfd063322244f5336cc7c6ffcfars * passing to standard system DNS APIs such as res_query(), or to the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * special-purpose functions included in this API that take fullname parameters.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See "Notes on DNS Name Escaping" earlier in this file for more details.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * hosttarget: The target hostname of the machine providing the service. This name can
4b22b9337f359bfd063322244f5336cc7c6ffcfars * be passed to functions like gethostbyname() to identify the host's IP address.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * port: The port, in network byte order, on which connections are accepted for this service.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtLen: The length of the txt record, in bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: The service's primary txt record, in standard txt record format.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: The context pointer that was passed to the callout.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * NOTE: In earlier versions of this header file, the txtRecord parameter was declared "const char *"
4b22b9337f359bfd063322244f5336cc7c6ffcfars * This is incorrect, since it contains length bytes which are values in the range 0 to 255, not -128 to +127.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Depending on your compiler settings, this change may cause signed/unsigned mismatch warnings.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * These should be fixed by updating your own callback function definition to match the corrected
4b22b9337f359bfd063322244f5336cc7c6ffcfars * function signature using "const unsigned char *txtRecord". Making this change may also fix inadvertent
4b22b9337f359bfd063322244f5336cc7c6ffcfars * bugs in your callback function, where it could have incorrectly interpreted a length byte with value 250
4b22b9337f359bfd063322244f5336cc7c6ffcfars * as being -6 instead, with various bad consequences ranging from incorrect operation to software crashes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If you need to maintain portable code that will compile cleanly with both the old and new versions of
4b22b9337f359bfd063322244f5336cc7c6ffcfars * this header file, you should update your callback function definition to use the correct unsigned value,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and then in the place where you pass your callback function to DNSServiceResolve(), use a cast to eliminate
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the compiler warning, e.g.:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceResolve(sd, flags, index, name, regtype, domain, (DNSServiceResolveReply)MyCallback, context);
4b22b9337f359bfd063322244f5336cc7c6ffcfars * This will ensure that your code compiles cleanly without warnings (and more importantly, works correctly)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * with both the old header and with the new corrected version.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef void (DNSSD_API *DNSServiceResolveReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *fullname,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *hosttarget,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t port, /* In network byte order */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t txtLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const unsigned char *txtRecord,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceResolve() Parameters
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and the resolve operation will run indefinitely until the client
4b22b9337f359bfd063322244f5336cc7c6ffcfars * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: Specifying kDNSServiceFlagsForceMulticast will cause query to be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * performed with a link-local mDNS query, even if the name is an
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * apparently non-local name (i.e. a name not ending in ".local.")
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaceIndex: The interface on which to resolve the service. If this resolve call is
4b22b9337f359bfd063322244f5336cc7c6ffcfars * as a result of a currently active DNSServiceBrowse() operation, then the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaceIndex should be the index reported in the DNSServiceBrowseReply
4b22b9337f359bfd063322244f5336cc7c6ffcfars * callback. If this resolve call is using information previously saved
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (e.g. in a preference file) for later use, then use interfaceIndex 0, because
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the desired service may now be reachable via a different physical interface.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See "Constants for specifying an interface index" for more details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * name: The name of the service instance to be resolved, as reported to the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceBrowseReply() callback.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * regtype: The type of the service instance to be resolved, as reported to the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceBrowseReply() callback.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * domain: The domain of the service instance to be resolved, as reported to the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceBrowseReply() callback.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * callBack: The function to be called when a result is found, or if the call
4b22b9337f359bfd063322244f5336cc7c6ffcfars * asynchronously fails.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: An application context pointer which is passed to the callback function
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (may be NULL).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errors are delivered to the callback), otherwise returns an error code indicating
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the error that occurred (the callback is never invoked and the DNSServiceRef
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is not initialized).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceResolve
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *name,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *regtype,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *domain,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceResolveReply callBack,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Querying Individual Specific Records
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceQueryRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Query for an arbitrary DNS record.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceQueryRecordReply() Callback Parameters:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: The DNSServiceRef initialized by DNSServiceQueryRecord().
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: Possible values are kDNSServiceFlagsMoreComing and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsAdd. The Add flag is NOT set for PTR records
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * with a ttl of 0, i.e. "Remove" events.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: The interface on which the query was resolved (the index for a given
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interface is determined via the if_nametoindex() family of calls).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * See "Constants for specifying an interface index" for more details.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * indicate the failure that occurred. Other parameters are undefined if
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * errorCode is nonzero.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * fullname: The resource record's full domain name.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * rrclass: The class of the resource record (usually kDNSServiceClass_IN).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * rdlen: The length, in bytes, of the resource record rdata.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * rdata: The raw rdata of the resource record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ttl: If the client wishes to cache the result for performance reasons,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the TTL indicates how long the client may legitimately hold onto
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * this result, in seconds. After the TTL expires, the client should
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * consider the result no longer valid, and if it requires this data
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * again, it should be re-fetched with a new query. Of course, this
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * only applies to clients that cancel the asynchronous operation when
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * they get a result. Clients that leave the asynchronous operation
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * running can safely assume that the data remains valid until they
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * get another callback telling them otherwise.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * context: The context pointer that was passed to the callout.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef void (DNSSD_API *DNSServiceQueryRecordReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char *fullname,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrtype,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrclass,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rdlen,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const void *rdata,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t ttl,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceQueryRecord() Parameters:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and the query operation will run indefinitely until the client
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: kDNSServiceFlagsForceMulticast or kDNSServiceFlagsLongLivedQuery.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Pass kDNSServiceFlagsLongLivedQuery to create a "long-lived" unicast
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * query to a unicast DNS server that implements the protocol. This flag
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * has no effect on link-local multicast queries.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: If non-zero, specifies the interface on which to issue the query
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * family of calls.) Passing 0 causes the name to be queried for on all
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaces. See "Constants for specifying an interface index" for more details.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * fullname: The full domain name of the resource record to be queried for.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * rrtype: The numerical type of the resource record to be queried for
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * rrclass: The class of the resource record (usually kDNSServiceClass_IN).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * callBack: The function to be called when a result is found, or if the call
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * asynchronously fails.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * context: An application context pointer which is passed to the callback function
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (may be NULL).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * errors are delivered to the callback), otherwise returns an error code indicating
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the error that occurred (the callback is never invoked and the DNSServiceRef
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is not initialized).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceQueryRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char *fullname,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrtype,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrclass,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceQueryRecordReply callBack,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Unified lookup of both IPv4 and IPv6 addresses for a fully qualified hostname
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceGetAddrInfo
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Queries for the IP address of a hostname by using either Multicast or Unicast DNS.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceGetAddrInfoReply() parameters:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: The DNSServiceRef initialized by DNSServiceGetAddrInfo().
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: Possible values are kDNSServiceFlagsMoreComing and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceFlagsAdd.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: The interface to which the answers pertain.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * indicate the failure that occurred. Other parameters are
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * undefined if errorCode is nonzero.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * hostname: The fully qualified domain name of the host to be queried for.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * address: IPv4 or IPv6 address.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ttl: If the client wishes to cache the result for performance reasons,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the TTL indicates how long the client may legitimately hold onto
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * this result, in seconds. After the TTL expires, the client should
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * consider the result no longer valid, and if it requires this data
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * again, it should be re-fetched with a new query. Of course, this
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * only applies to clients that cancel the asynchronous operation when
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * they get a result. Clients that leave the asynchronous operation
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * running can safely assume that the data remains valid until they
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * get another callback telling them otherwise.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * context: The context pointer that was passed to the callout.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef void (DNSSD_API *DNSServiceGetAddrInfoReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char *hostname,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const struct sockaddr *address,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t ttl,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceGetAddrInfo() Parameters:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds then it
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * initializes the DNSServiceRef, returns kDNSServiceErr_NoError, and the query
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * begins and will last indefinitely until the client terminates the query
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * by passing this DNSServiceRef to DNSServiceRefDeallocate().
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: kDNSServiceFlagsForceMulticast
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: The interface on which to issue the query. Passing 0 causes the query to be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sent on all active interfaces via Multicast or the primary interface via Unicast.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * protocol: Pass in kDNSServiceProtocol_IPv4 to look up IPv4 addresses, or kDNSServiceProtocol_IPv6
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to look up IPv6 addresses, or both to look up both kinds. If neither flag is
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * set, the system will apply an intelligent heuristic, which is (currently)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * that it will attempt to look up both, except:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * * If "hostname" is a wide-area unicast DNS hostname (i.e. not a ".local." name)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * but this host has no routable IPv6 address, then the call will not try to
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * look up IPv6 addresses for "hostname", since any addresses it found would be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * unlikely to be of any use anyway. Similarly, if this host has no routable
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * IPv4 address, the call will not try to look up IPv4 addresses for "hostname".
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * hostname: The fully qualified domain name of the host to be queried for.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * callBack: The function to be called when the query succeeds or fails asynchronously.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * context: An application context pointer which is passed to the callback function
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (may be NULL).
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * errors are delivered to the callback), otherwise returns an error code indicating
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the error that occurred.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceGetAddrInfo
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceProtocol protocol,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char *hostname,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceGetAddrInfoReply callBack,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* Special Purpose Calls:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* DNSServiceCreateConnection(), DNSServiceRegisterRecord(), DNSServiceReconfirmRecord()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* (most applications will not use these)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceCreateConnection()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Create a connection to the daemon allowing efficient registration of
4b22b9337f359bfd063322244f5336cc7c6ffcfars * multiple individual records.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the reference (via DNSServiceRefDeallocate()) severs the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * connection and deregisters all records registered on this connection.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
4b22b9337f359bfd063322244f5336cc7c6ffcfars * an error code indicating the specific failure that occurred (in which
4b22b9337f359bfd063322244f5336cc7c6ffcfars * case the DNSServiceRef is not initialized).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceCreateConnection(DNSServiceRef *sdRef);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceRegisterRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Register an individual resource record on a connected DNSServiceRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note that name conflicts occurring for records registered via this call must be handled
4b22b9337f359bfd063322244f5336cc7c6ffcfars * by the client in the callback.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRegisterRecordReply() parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: The connected DNSServiceRef initialized by
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceCreateConnection().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * RecordRef: The DNSRecordRef initialized by DNSServiceRegisterRecord(). If the above
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is
4b22b9337f359bfd063322244f5336cc7c6ffcfars * invalidated, and may not be used further.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Currently unused, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
4b22b9337f359bfd063322244f5336cc7c6ffcfars * indicate the failure that occurred (including name conflicts.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Other parameters are undefined if errorCode is nonzero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: The context pointer that was passed to the callout.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef void (DNSSD_API *DNSServiceRegisterRecordReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSRecordRef RecordRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceRegisterRecord() Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * sdRef: A DNSServiceRef initialized by DNSServiceCreateConnection().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
4b22b9337f359bfd063322244f5336cc7c6ffcfars * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (To deregister ALL records registered on a single connected DNSServiceRef
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and deallocate each of their corresponding DNSServiceRecordRefs, call
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRefDeallocate()).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * flags: Possible values are kDNSServiceFlagsShared or kDNSServiceFlagsUnique
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (see flag type definitions for details).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * interfaceIndex: If non-zero, specifies the interface on which to register the record
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (the index for a given interface is determined via the if_nametoindex()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * family of calls.) Passing 0 causes the record to be registered on all interfaces.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See "Constants for specifying an interface index" for more details.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * fullname: The full domain name of the resource record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rrtype: The numerical type of the resource record (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rrclass: The class of the resource record (usually kDNSServiceClass_IN)
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdlen: Length, in bytes, of the rdata.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ttl: The time to live of the resource record, in seconds.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Most clients should pass 0 to indicate that the system should
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * select a sensible default value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * callBack: The function to be called when a result is found, or if the call
4b22b9337f359bfd063322244f5336cc7c6ffcfars * asynchronously fails (e.g. because of a name conflict.)
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * context: An application context pointer which is passed to the callback function
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (may be NULL).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
4b22b9337f359bfd063322244f5336cc7c6ffcfars * errors are delivered to the callback), otherwise returns an error code indicating
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the error that occurred (the callback is never invoked and the DNSRecordRef is
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * not initialized).
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API DNSServiceRegisterRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
4b22b9337f359bfd063322244f5336cc7c6ffcfars DNSRecordRef *RecordRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *fullname,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrtype,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrclass,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rdlen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *rdata,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t ttl,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRegisterRecordReply callBack,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceReconfirmRecord
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Instruct the daemon to verify the validity of a resource record that appears
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to be out of date (e.g. because TCP connection to a service's target failed.)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Causes the record to be flushed from the daemon's cache (as well as all other
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * daemons' caches on the network) if the record is determined to be invalid.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Use this routine conservatively. Reconfirming a record necessarily consumes
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * network bandwidth, so this should not be done indiscriminately.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: Not currently used.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: Specifies the interface of the record in question.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The caller must specify the interface.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This API (by design) causes increased network traffic, so it requires
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the caller to be precise about which record should be reconfirmed.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * It is not possible to pass zero for the interface index to perform
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * a "wildcard" reconfirmation, where *all* matching records are reconfirmed.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * fullname: The resource record's full domain name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rrclass: The class of the resource record (usually kDNSServiceClass_IN).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdlen: The length, in bytes, of the resource record rdata.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * rdata: The raw rdata of the resource record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char *fullname,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrtype,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rrclass,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t rdlen,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const void *rdata
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* NAT Port Mapping
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceNATPortMappingCreate
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Request a port mapping in the NAT gateway, which maps a port on the local machine
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * to an external port on the NAT. The NAT should support either PCP, NAT-PMP or the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * UPnP/IGD protocol for this API to create a successful mapping. Note that this API
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * currently supports IPv4 addresses/mappings only. If the NAT gateway supports PCP and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * returns an IPv6 address (incorrectly, since this API specifically requests IPv4
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * addresses), the DNSServiceNATPortMappingReply callback will be invoked with errorCode
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * kDNSServiceErr_NATPortMappingUnsupported.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The port mapping will be renewed indefinitely until the client process exits, or
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * explicitly terminates the port mapping request by calling DNSServiceRefDeallocate().
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The client callback will be invoked, informing the client of the NAT gateway's
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * external IP address and the external port that has been allocated for this client.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The client should then record this external IP address and port using whatever
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * directory service mechanism it is using to enable peers to connect to it.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (Clients advertising services using Wide-Area DNS-SD DO NOT need to use this API
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * -- when a client calls DNSServiceRegister() NAT mappings are automatically created
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and the external IP address and port for the service are recorded in the global DNS.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Only clients using some directory mechanism other than Wide-Area DNS-SD need to use
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * this API to explicitly map their own ports.)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * It's possible that the client callback could be called multiple times, for example
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if the NAT gateway's IP address changes, or if a configuration change results in a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * different external port being mapped for this client. Over the lifetime of any long-lived
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * port mapping, the client should be prepared to handle these notifications of changes
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * in the environment, and should update its recorded address and/or port as appropriate.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * NOTE: There are two unusual aspects of how the DNSServiceNATPortMappingCreate API works,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * which were intentionally designed to help simplify client code:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 1. It's not an error to request a NAT mapping when the machine is not behind a NAT gateway.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * In other NAT mapping APIs, if you request a NAT mapping and the machine is not behind a NAT
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * gateway, then the API returns an error code -- it can't get you a NAT mapping if there's no
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * NAT gateway. The DNSServiceNATPortMappingCreate API takes a different view. Working out
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * whether or not you need a NAT mapping can be tricky and non-obvious, particularly on
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * a machine with multiple active network interfaces. Rather than make every client recreate
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * this logic for deciding whether a NAT mapping is required, the PortMapping API does that
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * work for you. If the client calls the PortMapping API when the machine already has a
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * routable public IP address, then instead of complaining about it and giving an error,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the PortMapping API just invokes your callback, giving the machine's public address
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and your own port number. This means you don't need to write code to work out whether
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * your client needs to call the PortMapping API -- just call it anyway, and if it wasn't
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * necessary, no harm is done:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * - If the machine already has a routable public IP address, then your callback
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * will just be invoked giving your own address and port.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * - If a NAT mapping is required and obtained, then your callback will be invoked
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * giving you the external address and port.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * - If a NAT mapping is required but not obtained from the local NAT gateway,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * or the machine has no network connectivity, then your callback will be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * invoked giving zero address and port.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 2. In other NAT mapping APIs, if a laptop computer is put to sleep and woken up on a new
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * network, it's the client's job to notice this, and work out whether a NAT mapping
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * is required on the new network, and make a new NAT mapping request if necessary.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The DNSServiceNATPortMappingCreate API does this for you, automatically.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The client just needs to make one call to the PortMapping API, and its callback will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * be invoked any time the mapping state changes. This property complements point (1) above.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If the client didn't make a NAT mapping request just because it determined that one was
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * not required at that particular moment in time, the client would then have to monitor
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * for network state changes to determine if a NAT port mapping later became necessary.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * By unconditionally making a NAT mapping request, even when a NAT mapping not to be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * necessary, the PortMapping API will then begin monitoring network state changes on behalf of
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the client, and if a NAT mapping later becomes necessary, it will automatically create a NAT
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * mapping and inform the client with a new callback giving the new address and port information.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceNATPortMappingReply() parameters:
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: The DNSServiceRef initialized by DNSServiceNATPortMappingCreate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: Currently unused, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: The interface through which the NAT gateway is reached.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * errorCode: Will be kDNSServiceErr_NoError on success.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Will be kDNSServiceErr_DoubleNAT when the NAT gateway is itself behind one or
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * more layers of NAT, in which case the other parameters have the defined values.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * For other failures, will indicate the failure that occurred, and the other
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * parameters are undefined.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * externalAddress: Four byte IPv4 address in network byte order.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * protocol: Will be kDNSServiceProtocol_UDP or kDNSServiceProtocol_TCP or both.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * internalPort: The port on the local machine that was mapped.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * externalPort: The actual external port in the NAT gateway that was mapped.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This is likely to be different than the requested external port.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ttl: The lifetime of the NAT port mapping created on the gateway.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * This controls how quickly stale mappings will be garbage-collected
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if the client machine crashes, suffers a power failure, is disconnected
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * from the network, or suffers some other unfortunate demise which
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * causes it to vanish without explicitly removing its NAT port mapping.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * It's possible that the ttl value will differ from the requested ttl value.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * context: The context pointer that was passed to the callout.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef void (DNSSD_API *DNSServiceNATPortMappingReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t externalAddress, /* four byte IPv4 address in network byte order */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceProtocol protocol,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t internalPort, /* In network byte order */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t externalPort, /* In network byte order and may be different than the requested port */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t ttl, /* may be different than the requested ttl */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* DNSServiceNATPortMappingCreate() Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds then it
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * initializes the DNSServiceRef, returns kDNSServiceErr_NoError, and the nat
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * port mapping will last indefinitely until the client terminates the port
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * mapping request by passing this DNSServiceRef to DNSServiceRefDeallocate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * flags: Currently ignored, reserved for future use.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * interfaceIndex: The interface on which to create port mappings in a NAT gateway. Passing 0 causes
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the port mapping request to be sent on the primary interface.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * protocol: To request a port mapping, pass in kDNSServiceProtocol_UDP, or kDNSServiceProtocol_TCP,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * or (kDNSServiceProtocol_UDP | kDNSServiceProtocol_TCP) to map both.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The local listening port number must also be specified in the internalPort parameter.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * To just discover the NAT gateway's external IP address, pass zero for protocol,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * internalPort, externalPort and ttl.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * internalPort: The port number in network byte order on the local machine which is listening for packets.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * externalPort: The requested external port in network byte order in the NAT gateway that you would
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * like to map to the internal port. Pass 0 if you don't care which external port is chosen for you.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * ttl: The requested renewal period of the NAT port mapping, in seconds.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If the client machine crashes, suffers a power failure, is disconnected from
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the network, or suffers some other unfortunate demise which causes it to vanish
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * unexpectedly without explicitly removing its NAT port mappings, then the NAT gateway
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * will garbage-collect old stale NAT port mappings when their lifetime expires.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Requesting a short TTL causes such orphaned mappings to be garbage-collected
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * more promptly, but consumes system resources and network bandwidth with
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * frequent renewal packets to keep the mapping from expiring.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Requesting a long TTL is more efficient on the network, but in the event of the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * client vanishing, stale NAT port mappings will not be garbage-collected as quickly.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Most clients should pass 0 to use a system-wide default value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * callBack: The function to be called when the port mapping request succeeds or fails asynchronously.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * context: An application context pointer which is passed to the callback function
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * (may be NULL).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success (any subsequent, asynchronous
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * errors are delivered to the callback), otherwise returns an error code indicating
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the error that occurred.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If you don't actually want a port mapped, and are just calling the API
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * because you want to find out the NAT's external IP address (e.g. for UI
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * display) then pass zero for protocol, internalPort, externalPort and ttl.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceNATPortMappingCreate
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t interfaceIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceProtocol protocol, /* TCP and/or UDP */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t internalPort, /* network byte order */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t externalPort, /* network byte order */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint32_t ttl, /* time to live in seconds */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceNATPortMappingReply callBack,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* General Utility Functions
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* DNSServiceConstructFullName()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Concatenate a three-part domain name (as returned by the above callbacks) into a
4b22b9337f359bfd063322244f5336cc7c6ffcfars * properly-escaped full domain name. Note that callbacks in the above functions ALREADY ESCAPE
4b22b9337f359bfd063322244f5336cc7c6ffcfars * strings where necessary.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Parameters:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * fullName: A pointer to a buffer that where the resulting full domain name is to be written.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * The buffer must be kDNSServiceMaxDomainName (1009) bytes in length to
4b22b9337f359bfd063322244f5336cc7c6ffcfars * accommodate the longest legal domain name without buffer overrun.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * service: The service name - any dots or backslashes must NOT be escaped.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * May be NULL (to construct a PTR record name, e.g.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * "_ftp._tcp.apple.com.").
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * regtype: The service type followed by the protocol, separated by a dot
4b22b9337f359bfd063322244f5336cc7c6ffcfars * (e.g. "_ftp._tcp").
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * domain: The domain name, e.g. "apple.com.". Literal dots or backslashes,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * if any, must be escaped, e.g. "1st\. Floor.apple.com."
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError (0) on success, kDNSServiceErr_BadParam on error.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceConstructFullName
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome char * const fullName,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char * const service, /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char * const regtype,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome const char * const domain
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* TXT Record Construction Functions
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * A typical calling sequence for TXT record construction is something like:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Client allocates storage for TXTRecord data (e.g. declare buffer on the stack)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXTRecordCreate();
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXTRecordSetValue();
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXTRecordSetValue();
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXTRecordSetValue();
4b22b9337f359bfd063322244f5336cc7c6ffcfars * ...
4b22b9337f359bfd063322244f5336cc7c6ffcfars * DNSServiceRegister( ... TXTRecordGetLength(), TXTRecordGetBytesPtr() ... );
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXTRecordDeallocate();
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Explicitly deallocate storage for TXTRecord data (if not allocated on the stack)
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordRef
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Opaque internal data type.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: Represents a DNS-SD TXT record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef union _TXTRecordRef_t { char PrivateData[16]; char *ForceNaturalAlignment; } TXTRecordRef;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordCreate()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Creates a new empty TXTRecordRef referencing the specified storage.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If the buffer parameter is NULL, or the specified storage size is not
4b22b9337f359bfd063322244f5336cc7c6ffcfars * large enough to hold a key subsequently added using TXTRecordSetValue(),
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then additional memory will be added as needed using malloc().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * On some platforms, when memory is low, malloc() may fail. In this
4b22b9337f359bfd063322244f5336cc7c6ffcfars * case, TXTRecordSetValue() will return kDNSServiceErr_NoMemory, and this
4b22b9337f359bfd063322244f5336cc7c6ffcfars * error condition will need to be handled as appropriate by the caller.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * You can avoid the need to handle this error condition if you ensure
4b22b9337f359bfd063322244f5336cc7c6ffcfars * that the storage you initially provide is large enough to hold all
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the key/value pairs that are to be added to the record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The caller can precompute the exact length required for all of the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * key/value pairs to be added, or simply provide a fixed-sized buffer
4b22b9337f359bfd063322244f5336cc7c6ffcfars * known in advance to be large enough.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * A no-value (key-only) key requires (1 + key length) bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * A key with empty value requires (1 + key length + 1) bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * A key with non-empty value requires (1 + key length + 1 + value length).
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For most applications, DNS-SD TXT records are generally
4b22b9337f359bfd063322244f5336cc7c6ffcfars * less than 100 bytes, so in most cases a simple fixed-sized
4b22b9337f359bfd063322244f5336cc7c6ffcfars * 256-byte buffer will be more than sufficient.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Recommended size limits for DNS-SD TXT Records are discussed in
4b22b9337f359bfd063322244f5336cc7c6ffcfars * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Note: When passing parameters to and from these TXT record APIs,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the key name does not include the '=' character. The '=' character
4b22b9337f359bfd063322244f5336cc7c6ffcfars * is the separator between the key and value in the on-the-wire
4b22b9337f359bfd063322244f5336cc7c6ffcfars * packet format; it is not part of either the key or the value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: A pointer to an uninitialized TXTRecordRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * bufferLen: The size of the storage provided in the "buffer" parameter.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * buffer: Optional caller-supplied storage used to hold the TXTRecord data.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * This storage must remain valid for as long as
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the TXTRecordRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsvoid DNSSD_API TXTRecordCreate
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars TXTRecordRef *txtRecord,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t bufferLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars void *buffer
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordDeallocate()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Releases any resources allocated in the course of preparing a TXT Record
4b22b9337f359bfd063322244f5336cc7c6ffcfars * using TXTRecordCreate()/TXTRecordSetValue()/TXTRecordRemoveValue().
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Ownership of the buffer provided in TXTRecordCreate() returns to the client.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsvoid DNSSD_API TXTRecordDeallocate
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars TXTRecordRef *txtRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordSetValue()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Adds a key (optionally with value) to a TXTRecordRef. If the "key" already
4b22b9337f359bfd063322244f5336cc7c6ffcfars * exists in the TXTRecordRef, then the current value will be replaced with
4b22b9337f359bfd063322244f5336cc7c6ffcfars * the new value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Keys may exist in four states with respect to a given TXT record:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * - Absent (key does not appear at all)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * - Present with no value ("key" appears alone)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * - Present with empty value ("key=" appears in TXT record)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * - Present with non-empty value ("key=value" appears in TXT record)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For more details refer to "Data Syntax for DNS-SD TXT Records" in
4b22b9337f359bfd063322244f5336cc7c6ffcfars * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * key: A null-terminated string which only contains printable ASCII
4b22b9337f359bfd063322244f5336cc7c6ffcfars * values (0x20-0x7E), excluding '=' (0x3D). Keys should be
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 9 characters or fewer (not counting the terminating null).
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * valueSize: The size of the value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * value: Any binary value. For values that represent
4b22b9337f359bfd063322244f5336cc7c6ffcfars * textual data, UTF-8 is STRONGLY recommended.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For values that represent textual data, valueSize
4b22b9337f359bfd063322244f5336cc7c6ffcfars * should NOT include the terminating null (if any)
4b22b9337f359bfd063322244f5336cc7c6ffcfars * at the end of the string.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If NULL, then "key" will be added with no value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If non-NULL but valueSize is zero, then "key=" will be
4b22b9337f359bfd063322244f5336cc7c6ffcfars * added with empty value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Returns kDNSServiceErr_Invalid if the "key" string contains
4b22b9337f359bfd063322244f5336cc7c6ffcfars * illegal characters.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Returns kDNSServiceErr_NoMemory if adding this key would
4b22b9337f359bfd063322244f5336cc7c6ffcfars * exceed the available storage.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API TXTRecordSetValue
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars TXTRecordRef *txtRecord,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *key,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint8_t valueSize, /* may be zero */
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *value /* may be NULL */
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordRemoveValue()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Removes a key from a TXTRecordRef. The "key" must be an
4b22b9337f359bfd063322244f5336cc7c6ffcfars * ASCII string which exists in the TXTRecordRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * key: A key name which exists in the TXTRecordRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Returns kDNSServiceErr_NoSuchKey if the "key" does not
4b22b9337f359bfd063322244f5336cc7c6ffcfars * exist in the TXTRecordRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API TXTRecordRemoveValue
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars TXTRecordRef *txtRecord,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *key
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordGetLength()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Allows you to determine the length of the raw bytes within a TXTRecordRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns the size of the raw bytes inside a TXTRecordRef
4b22b9337f359bfd063322244f5336cc7c6ffcfars * which you can pass directly to DNSServiceRegister() or
4b22b9337f359bfd063322244f5336cc7c6ffcfars * to DNSServiceUpdateRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Returns 0 if the TXTRecordRef is empty.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsuint16_t DNSSD_API TXTRecordGetLength
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars const TXTRecordRef *txtRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordGetBytesPtr()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Allows you to retrieve a pointer to the raw bytes within a TXTRecordRef.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns a pointer to the raw bytes inside the TXTRecordRef
4b22b9337f359bfd063322244f5336cc7c6ffcfars * which you can pass directly to DNSServiceRegister() or
4b22b9337f359bfd063322244f5336cc7c6ffcfars * to DNSServiceUpdateRecord().
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsconst void * DNSSD_API TXTRecordGetBytesPtr
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
4b22b9337f359bfd063322244f5336cc7c6ffcfars const TXTRecordRef *txtRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*********************************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome* TXT Record Parsing Functions
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome*********************************************************************************************/
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * A typical calling sequence for TXT record parsing is something like:
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Receive TXT record data in DNSServiceResolve() callback
4b22b9337f359bfd063322244f5336cc7c6ffcfars * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
4b22b9337f359bfd063322244f5336cc7c6ffcfars * val1ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key1", &len1);
4b22b9337f359bfd063322244f5336cc7c6ffcfars * val2ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key2", &len2);
4b22b9337f359bfd063322244f5336cc7c6ffcfars * ...
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * memcpy(myval1, val1ptr, len1);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * memcpy(myval2, val2ptr, len2);
4b22b9337f359bfd063322244f5336cc7c6ffcfars * ...
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return;
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If you wish to retain the values after return from the DNSServiceResolve()
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * callback, then you need to copy the data to your own storage using memcpy()
4b22b9337f359bfd063322244f5336cc7c6ffcfars * or similar, as shown in the example above.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If for some reason you need to parse a TXT record you built yourself
4b22b9337f359bfd063322244f5336cc7c6ffcfars * using the TXT record construction functions above, then you can do
4b22b9337f359bfd063322244f5336cc7c6ffcfars * that using TXTRecordGetLength and TXTRecordGetBytesPtr calls:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXTRecordGetValue(TXTRecordGetLength(x), TXTRecordGetBytesPtr(x), key, &len);
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Most applications only fetch keys they know about from a TXT record and
4b22b9337f359bfd063322244f5336cc7c6ffcfars * ignore the rest.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * However, some debugging tools wish to fetch and display all keys.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * To do that, use the TXTRecordGetCount() and TXTRecordGetItemAtIndex() calls.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordContainsKey()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Allows you to determine if a given TXT Record contains a specified key.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtLen: The size of the received TXT Record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: Pointer to the received TXT Record bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * key: A null-terminated ASCII string containing the key name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns 1 if the TXT Record contains the specified key.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Otherwise, it returns 0.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsint DNSSD_API TXTRecordContainsKey
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t txtLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *txtRecord,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *key
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordGetValuePtr()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Allows you to retrieve the value for a given key from a TXT Record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtLen: The size of the received TXT Record
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: Pointer to the received TXT Record bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * key: A null-terminated ASCII string containing the key name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * valueLen: On output, will be set to the size of the "value" data.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns NULL if the key does not exist in this TXT record,
4b22b9337f359bfd063322244f5336cc7c6ffcfars * or exists with no value (to differentiate between
4b22b9337f359bfd063322244f5336cc7c6ffcfars * these two cases use TXTRecordContainsKey()).
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Returns pointer to location within TXT Record bytes
4b22b9337f359bfd063322244f5336cc7c6ffcfars * if the key exists with empty or non-empty value.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For empty value, valueLen will be zero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For non-empty value, valueLen will be length of value data.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsconst void * DNSSD_API TXTRecordGetValuePtr
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t txtLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *txtRecord,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const char *key,
4b22b9337f359bfd063322244f5336cc7c6ffcfars uint8_t *valueLen
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordGetCount()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Returns the number of keys stored in the TXT Record. The count
4b22b9337f359bfd063322244f5336cc7c6ffcfars * can be used with TXTRecordGetItemAtIndex() to iterate through the keys.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtLen: The size of the received TXT Record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: Pointer to the received TXT Record bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns the total number of keys in the TXT Record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsuint16_t DNSSD_API TXTRecordGetCount
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t txtLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *txtRecord
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* TXTRecordGetItemAtIndex()
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Allows you to retrieve a key name and value pointer, given an index into
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * It's also possible to iterate through keys in a TXT record by simply
4b22b9337f359bfd063322244f5336cc7c6ffcfars * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * On return:
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For keys with no value, *value is set to NULL and *valueLen is zero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For keys with empty value, *value is non-NULL and *valueLen is zero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtLen: The size of the received TXT Record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * txtRecord: Pointer to the received TXT Record bytes.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * itemIndex: An index into the TXT Record.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * keyBufLen: The size of the string buffer being supplied.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * key: A string buffer used to store the key name.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * On return, the buffer contains a null-terminated C string
4b22b9337f359bfd063322244f5336cc7c6ffcfars * giving the key name. DNS-SD TXT keys are usually
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * 9 characters or fewer. To hold the maximum possible
4b22b9337f359bfd063322244f5336cc7c6ffcfars * key name, the buffer should be 256 bytes long.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * valueLen: On output, will be set to the size of the "value" data.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * value: On output, *value is set to point to location within TXT
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Record bytes that holds the value data.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * return value: Returns kDNSServiceErr_NoError on success.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Returns kDNSServiceErr_NoMemory if keyBufLen is too short.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Returns kDNSServiceErr_Invalid if index is greater than
4b22b9337f359bfd063322244f5336cc7c6ffcfars * TXTRecordGetCount()-1.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsDNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t txtLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void *txtRecord,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t itemIndex,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome uint16_t keyBufLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars char *key,
4b22b9337f359bfd063322244f5336cc7c6ffcfars uint8_t *valueLen,
4b22b9337f359bfd063322244f5336cc7c6ffcfars const void **value
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#if _DNS_SD_LIBDISPATCH
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceSetDispatchQueue
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Allows you to schedule a DNSServiceRef on a serial dispatch queue for receiving asynchronous
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * callbacks. It's the clients responsibility to ensure that the provided dispatch queue is running.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * A typical application that uses CFRunLoopRun or dispatch_main on its main thread will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * usually schedule DNSServiceRefs on its main queue (which is always a serial queue)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * using "DNSServiceSetDispatchQueue(sdref, dispatch_get_main_queue());"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * If there is any error during the processing of events, the application callback will
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * be called with an error code. For shared connections, each subordinate DNSServiceRef
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * will get its own error callback. Currently these error callbacks only happen
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * if the daemon is manually terminated or crashes, and the error
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * code in this case is kDNSServiceErr_ServiceNotRunning. The application must call
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceRefDeallocate to free the DNSServiceRef when it gets such an error code.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * These error callbacks are rare and should not normally happen on customer machines,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * but application code should be written defensively to handle such error callbacks
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * gracefully if they occur.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * After using DNSServiceSetDispatchQueue on a DNSServiceRef, calling DNSServiceProcessResult
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * on the same DNSServiceRef will result in undefined behavior and should be avoided.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Once the application successfully schedules a DNSServiceRef on a serial dispatch queue using
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceSetDispatchQueue, it cannot remove the DNSServiceRef from the dispatch queue, or use
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * DNSServiceSetDispatchQueue a second time to schedule the DNSServiceRef onto a different serial dispatch
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * queue. Once scheduled onto a dispatch queue a DNSServiceRef will deliver events to that queue until
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * the application no longer requires that operation and terminates it using DNSServiceRefDeallocate.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * service: DNSServiceRef that was allocated and returned to the application, when the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * application calls one of the DNSService API.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * queue: dispatch queue where the application callback will be scheduled
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome *
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * return value: Returns kDNSServiceErr_NoError on success.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Returns kDNSServiceErr_NoMemory if it cannot create a dispatch source
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Returns kDNSServiceErr_BadParam if the service param is invalid or the
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * queue param is invalid
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceSetDispatchQueue
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef service,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome dispatch_queue_t queue
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#endif //_DNS_SD_LIBDISPATCH
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#if !defined(_WIN32)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soometypedef void (DNSSD_API *DNSServiceSleepKeepaliveReply)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceErrorType errorCode,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomeDNSServiceErrorType DNSSD_API DNSServiceSleepKeepalive
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome(
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceRef *sdRef,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceFlags flags,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome int fd,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome unsigned int timeout,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome DNSServiceSleepKeepaliveReply callBack,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome void *context
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#endif
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#ifdef __APPLE_API_PRIVATE
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceCompPrivateDNS "PrivateDNS"
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome#define kDNSServiceCompMulticastDNS "MulticastDNS"
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif //__APPLE_API_PRIVATE
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* Some C compiler cleverness. We can make the compiler check certain things for us,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * and report errors at compile-time if anything is wrong. The usual way to do this would
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * be to use a run-time "if" statement or the conventional run-time "assert" mechanism, but
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * then you don't find out what's wrong until you run the software. This way, if the assertion
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * condition is false, the array size is negative, and the complier complains immediately.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soomestruct CompileTimeAssertionChecks_DNS_SD
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome{
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome char assert0[(sizeof(union _TXTRecordRef_t) == 16) ? 1 : -1];
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome};
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifdef __cplusplus
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome}
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif /* _DNS_SD_H */