2N/A/* -*- Mode: C; tab-width: 4 -*-
2N/A *
2N/A * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions are met:
2N/A *
2N/A * 1. Redistributions of source code must retain the above copyright notice,
2N/A * this list of conditions and the following disclaimer.
2N/A * 2. Redistributions in binary form must reproduce the above copyright notice,
2N/A * this list of conditions and the following disclaimer in the documentation
2N/A * and/or other materials provided with the distribution.
2N/A * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
2N/A * contributors may be used to endorse or promote products derived from this
2N/A * software without specific prior written permission.
2N/A *
2N/A * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
2N/A * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2N/A * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2N/A * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
2N/A * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2N/A * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2N/A * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2N/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2N/A * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2N/A */
2N/A
2N/A#ifndef _DNS_SD_H
2N/A#define _DNS_SD_H
2N/A
2N/A#ifdef __cplusplus
2N/A extern "C" {
2N/A#endif
2N/A
2N/A/* standard calling convention under Win32 is __stdcall */
2N/A/* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */
2N/A/* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */
2N/A#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
2N/A#define DNSSD_API __stdcall
2N/A#else
2N/A#define DNSSD_API
2N/A#endif
2N/A
2N/A/* stdint.h does not exist on FreeBSD 4.x; its types are defined in sys/types.h instead */
2N/A#if defined(__FreeBSD__) && (__FreeBSD__ < 5)
2N/A#include <sys/types.h>
2N/A
2N/A/* Likewise, on Sun, standard integer types are in sys/types.h */
2N/A#elif defined(__sun__)
2N/A#include <sys/types.h>
2N/A
2N/A/* EFI does not have stdint.h, or anything else equivalent */
2N/A#elif defined(EFI32) || defined(EFI64)
2N/Atypedef UINT8 uint8_t;
2N/Atypedef INT8 int8_t;
2N/Atypedef UINT16 uint16_t;
2N/Atypedef INT16 int16_t;
2N/Atypedef UINT32 uint32_t;
2N/Atypedef INT32 int32_t;
2N/A
2N/A/* Windows has its own differences */
2N/A#elif defined(_WIN32)
2N/A#include <windows.h>
2N/A#define _UNUSED
2N/A#define bzero(a, b) memset(a, 0, b)
2N/A#ifndef _MSL_STDINT_H
2N/Atypedef UINT8 uint8_t;
2N/Atypedef INT8 int8_t;
2N/Atypedef UINT16 uint16_t;
2N/Atypedef INT16 int16_t;
2N/Atypedef UINT32 uint32_t;
2N/Atypedef INT32 int32_t;
2N/A#endif
2N/A
2N/A/* All other Posix platforms use stdint.h */
2N/A#else
2N/A#include <stdint.h>
2N/A#include <strings.h>
2N/A#endif
2N/A
2N/A/* DNSServiceRef, DNSRecordRef
2N/A *
2N/A * Opaque internal data types.
2N/A * Note: client is responsible for serializing access to these structures if
2N/A * they are shared between concurrent threads.
2N/A */
2N/A
2N/Atypedef struct _DNSServiceRef_t *DNSServiceRef;
2N/Atypedef struct _DNSRecordRef_t *DNSRecordRef;
2N/A
2N/A/* General flags used in functions defined below */
2N/Aenum
2N/A {
2N/A kDNSServiceFlagsMoreComing = 0x1,
2N/A /* MoreComing indicates to a callback that at least one more result is
2N/A * queued and will be delivered following immediately after this one.
2N/A * Applications should not update their UI to display browse
2N/A * results when the MoreComing flag is set, because this would
2N/A * result in a great deal of ugly flickering on the screen.
2N/A * Applications should instead wait until until MoreComing is not set,
2N/A * and then update their UI.
2N/A * When MoreComing is not set, that doesn't mean there will be no more
2N/A * answers EVER, just that there are no more answers immediately
2N/A * available right now at this instant. If more answers become available
2N/A * in the future they will be delivered as usual.
2N/A */
2N/A
2N/A kDNSServiceFlagsAdd = 0x2,
2N/A kDNSServiceFlagsDefault = 0x4,
2N/A /* Flags for domain enumeration and browse/query reply callbacks.
2N/A * "Default" applies only to enumeration and is only valid in
2N/A * conjuction with "Add". An enumeration callback with the "Add"
2N/A * flag NOT set indicates a "Remove", i.e. the domain is no longer
2N/A * valid.
2N/A */
2N/A
2N/A kDNSServiceFlagsNoAutoRename = 0x8,
2N/A /* Flag for specifying renaming behavior on name conflict when registering
2N/A * non-shared records. By default, name conflicts are automatically handled
2N/A * by renaming the service. NoAutoRename overrides this behavior - with this
2N/A * flag set, name conflicts will result in a callback. The NoAutorename flag
2N/A * is only valid if a name is explicitly specified when registering a service
2N/A * (i.e. the default name is not used.)
2N/A */
2N/A
2N/A kDNSServiceFlagsShared = 0x10,
2N/A kDNSServiceFlagsUnique = 0x20,
2N/A /* Flag for registering individual records on a connected
2N/A * DNSServiceRef. Shared indicates that there may be multiple records
2N/A * with this name on the network (e.g. PTR records). Unique indicates that the
2N/A * record's name is to be unique on the network (e.g. SRV records).
2N/A */
2N/A
2N/A kDNSServiceFlagsBrowseDomains = 0x40,
2N/A kDNSServiceFlagsRegistrationDomains = 0x80,
2N/A /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains.
2N/A * BrowseDomains enumerates domains recommended for browsing, RegistrationDomains
2N/A * enumerates domains recommended for registration.
2N/A */
2N/A
2N/A kDNSServiceFlagsLongLivedQuery = 0x100,
2N/A /* Flag for creating a long-lived unicast query for the DNSServiceQueryRecord call. */
2N/A
2N/A kDNSServiceFlagsAllowRemoteQuery = 0x200,
2N/A /* Flag for creating a record for which we will answer remote queries
2N/A * (queries from hosts more than one hop away; hosts not directly connected to the local link).
2N/A */
2N/A
2N/A kDNSServiceFlagsForceMulticast = 0x400,
2N/A /* Flag for signifying that a query or registration should be performed exclusively via multicast DNS,
2N/A * even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS.
2N/A */
2N/A
2N/A kDNSServiceFlagsReturnCNAME = 0x800
2N/A /* Flag for returning CNAME records in the DNSServiceQueryRecord call. CNAME records are
2N/A * normally followed without indicating to the client that there was a CNAME record.
2N/A */
2N/A };
2N/A
2N/A/*
2N/A * The values for DNS Classes and Types are listed in RFC 1035, and are available
2N/A * on every OS in its DNS header file. Unfortunately every OS does not have the
2N/A * same header file containing DNS Class and Type constants, and the names of
2N/A * the constants are not consistent. For example, BIND 8 uses "T_A",
2N/A * BIND 9 uses "ns_t_a", Windows uses "DNS_TYPE_A", etc.
2N/A * For this reason, these constants are also listed here, so that code using
2N/A * the DNS-SD programming APIs can use these constants, so that the same code
2N/A * can compile on all our supported platforms.
2N/A */
2N/A
2N/Aenum
2N/A {
2N/A kDNSServiceClass_IN = 1 /* Internet */
2N/A };
2N/A
2N/Aenum
2N/A {
2N/A kDNSServiceType_A = 1, /* Host address. */
2N/A kDNSServiceType_NS = 2, /* Authoritative server. */
2N/A kDNSServiceType_MD = 3, /* Mail destination. */
2N/A kDNSServiceType_MF = 4, /* Mail forwarder. */
2N/A kDNSServiceType_CNAME = 5, /* Canonical name. */
2N/A kDNSServiceType_SOA = 6, /* Start of authority zone. */
2N/A kDNSServiceType_MB = 7, /* Mailbox domain name. */
2N/A kDNSServiceType_MG = 8, /* Mail group member. */
2N/A kDNSServiceType_MR = 9, /* Mail rename name. */
2N/A kDNSServiceType_NULL = 10, /* Null resource record. */
2N/A kDNSServiceType_WKS = 11, /* Well known service. */
2N/A kDNSServiceType_PTR = 12, /* Domain name pointer. */
2N/A kDNSServiceType_HINFO = 13, /* Host information. */
2N/A kDNSServiceType_MINFO = 14, /* Mailbox information. */
2N/A kDNSServiceType_MX = 15, /* Mail routing information. */
2N/A kDNSServiceType_TXT = 16, /* One or more text strings. */
2N/A kDNSServiceType_RP = 17, /* Responsible person. */
2N/A kDNSServiceType_AFSDB = 18, /* AFS cell database. */
2N/A kDNSServiceType_X25 = 19, /* X_25 calling address. */
2N/A kDNSServiceType_ISDN = 20, /* ISDN calling address. */
2N/A kDNSServiceType_RT = 21, /* Router. */
2N/A kDNSServiceType_NSAP = 22, /* NSAP address. */
2N/A kDNSServiceType_NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated). */
2N/A kDNSServiceType_SIG = 24, /* Security signature. */
2N/A kDNSServiceType_KEY = 25, /* Security key. */
2N/A kDNSServiceType_PX = 26, /* X.400 mail mapping. */
2N/A kDNSServiceType_GPOS = 27, /* Geographical position (withdrawn). */
2N/A kDNSServiceType_AAAA = 28, /* IPv6 Address. */
2N/A kDNSServiceType_LOC = 29, /* Location Information. */
2N/A kDNSServiceType_NXT = 30, /* Next domain (security). */
2N/A kDNSServiceType_EID = 31, /* Endpoint identifier. */
2N/A kDNSServiceType_NIMLOC = 32, /* Nimrod Locator. */
2N/A kDNSServiceType_SRV = 33, /* Server Selection. */
2N/A kDNSServiceType_ATMA = 34, /* ATM Address */
2N/A kDNSServiceType_NAPTR = 35, /* Naming Authority PoinTeR */
2N/A kDNSServiceType_KX = 36, /* Key Exchange */
2N/A kDNSServiceType_CERT = 37, /* Certification record */
2N/A kDNSServiceType_A6 = 38, /* IPv6 Address (deprecated) */
2N/A kDNSServiceType_DNAME = 39, /* Non-terminal DNAME (for IPv6) */
2N/A kDNSServiceType_SINK = 40, /* Kitchen sink (experimentatl) */
2N/A kDNSServiceType_OPT = 41, /* EDNS0 option (meta-RR) */
2N/A kDNSServiceType_TKEY = 249, /* Transaction key */
2N/A kDNSServiceType_TSIG = 250, /* Transaction signature. */
2N/A kDNSServiceType_IXFR = 251, /* Incremental zone transfer. */
2N/A kDNSServiceType_AXFR = 252, /* Transfer zone of authority. */
2N/A kDNSServiceType_MAILB = 253, /* Transfer mailbox records. */
2N/A kDNSServiceType_MAILA = 254, /* Transfer mail agent records. */
2N/A kDNSServiceType_ANY = 255 /* Wildcard match. */
2N/A };
2N/A
2N/A
2N/A/* possible error code values */
2N/Aenum
2N/A {
2N/A kDNSServiceErr_NoError = 0,
2N/A kDNSServiceErr_Unknown = -65537, /* 0xFFFE FFFF */
2N/A kDNSServiceErr_NoSuchName = -65538,
2N/A kDNSServiceErr_NoMemory = -65539,
2N/A kDNSServiceErr_BadParam = -65540,
2N/A kDNSServiceErr_BadReference = -65541,
2N/A kDNSServiceErr_BadState = -65542,
2N/A kDNSServiceErr_BadFlags = -65543,
2N/A kDNSServiceErr_Unsupported = -65544,
2N/A kDNSServiceErr_NotInitialized = -65545,
2N/A kDNSServiceErr_AlreadyRegistered = -65547,
2N/A kDNSServiceErr_NameConflict = -65548,
2N/A kDNSServiceErr_Invalid = -65549,
2N/A kDNSServiceErr_Firewall = -65550,
2N/A kDNSServiceErr_Incompatible = -65551, /* client library incompatible with daemon */
2N/A kDNSServiceErr_BadInterfaceIndex = -65552,
2N/A kDNSServiceErr_Refused = -65553,
2N/A kDNSServiceErr_NoSuchRecord = -65554,
2N/A kDNSServiceErr_NoAuth = -65555,
2N/A kDNSServiceErr_NoSuchKey = -65556,
2N/A kDNSServiceErr_NATTraversal = -65557,
2N/A kDNSServiceErr_DoubleNAT = -65558,
2N/A kDNSServiceErr_BadTime = -65559
2N/A /* mDNS Error codes are in the range
2N/A * FFFE FF00 (-65792) to FFFE FFFF (-65537) */
2N/A };
2N/A
2N/A
2N/A/* Maximum length, in bytes, of a service name represented as a */
2N/A/* literal C-String, including the terminating NULL at the end. */
2N/A
2N/A#define kDNSServiceMaxServiceName 64
2N/A
2N/A/* Maximum length, in bytes, of a domain name represented as an *escaped* C-String */
2N/A/* including the final trailing dot, and the C-String terminating NULL at the end. */
2N/A
2N/A#define kDNSServiceMaxDomainName 1005
2N/A
2N/A/*
2N/A * Notes on DNS Name Escaping
2N/A * -- or --
2N/A * "Why is kDNSServiceMaxDomainName 1005, when the maximum legal domain name is 255 bytes?"
2N/A *
2N/A * All strings used in DNS-SD are UTF-8 strings.
2N/A * With few exceptions, most are also escaped using standard DNS escaping rules:
2N/A *
2N/A * '\\' represents a single literal '\' in the name
2N/A * '\.' represents a single literal '.' in the name
2N/A * '\ddd', where ddd is a three-digit decimal value from 000 to 255,
2N/A * represents a single literal byte with that value.
2N/A * A bare unescaped '.' is a label separator, marking a boundary between domain and subdomain.
2N/A *
2N/A * The exceptions, that do not use escaping, are the routines where the full
2N/A * DNS name of a resource is broken, for convenience, into servicename/regtype/domain.
2N/A * In these routines, the "servicename" is NOT escaped. It does not need to be, since
2N/A * it is, by definition, just a single literal string. Any characters in that string
2N/A * represent exactly what they are. The "regtype" portion is, technically speaking,
2N/A * escaped, but since legal regtypes are only allowed to contain letters, digits,
2N/A * and hyphens, there is nothing to escape, so the issue is moot. The "domain"
2N/A * portion is also escaped, though most domains in use on the public Internet
2N/A * today, like regtypes, don't contain any characters that need to be escaped.
2N/A * As DNS-SD becomes more popular, rich-text domains for service discovery will
2N/A * become common, so software should be written to cope with domains with escaping.
2N/A *
2N/A * The servicename may be up to 63 bytes of UTF-8 text (not counting the C-String
2N/A * terminating NULL at the end). The regtype is of the form _service._tcp or
2N/A * _service._udp, where the "service" part is 1-14 characters, which may be
2N/A * letters, digits, or hyphens. The domain part of the three-part name may be
2N/A * any legal domain, providing that the resulting servicename+regtype+domain
2N/A * name does not exceed 255 bytes.
2N/A *
2N/A * For most software, these issues are transparent. When browsing, the discovered
2N/A * servicenames should simply be displayed as-is. When resolving, the discovered
2N/A * servicename/regtype/domain are simply passed unchanged to DNSServiceResolve().
2N/A * When a DNSServiceResolve() succeeds, the returned fullname is already in
2N/A * the correct format to pass to standard system DNS APIs such as res_query().
2N/A * For converting from servicename/regtype/domain to a single properly-escaped
2N/A * full DNS name, the helper function DNSServiceConstructFullName() is provided.
2N/A *
2N/A * The following (highly contrived) example illustrates the escaping process.
2N/A * Suppose you have an service called "Dr. Smith\Dr. Johnson", of type "_ftp._tcp"
2N/A * in subdomain "4th. Floor" of subdomain "Building 2" of domain "apple.com."
2N/A * The full (escaped) DNS name of this service's SRV record would be:
2N/A * Dr\.\032Smith\\Dr\.\032Johnson._ftp._tcp.4th\.\032Floor.Building\0322.apple.com.
2N/A */
2N/A
2N/A
2N/A/*
2N/A * Constants for specifying an interface index
2N/A *
2N/A * Specific interface indexes are identified via a 32-bit unsigned integer returned
2N/A * by the if_nametoindex() family of calls.
2N/A *
2N/A * If the client passes 0 for interface index, that means "do the right thing",
2N/A * which (at present) means, "if the name is in an mDNS local multicast domain
2N/A * (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast
2N/A * on all applicable interfaces, otherwise send via unicast to the appropriate
2N/A * DNS server." Normally, most clients will use 0 for interface index to
2N/A * automatically get the default sensible behaviour.
2N/A *
2N/A * If the client passes a positive interface index, then for multicast names that
2N/A * indicates to do the operation only on that one interface. For unicast names the
2N/A * interface index is ignored unless kDNSServiceFlagsForceMulticast is also set.
2N/A *
2N/A * If the client passes kDNSServiceInterfaceIndexLocalOnly when registering
2N/A * a service, then that service will be found *only* by other local clients
2N/A * on the same machine that are browsing using kDNSServiceInterfaceIndexLocalOnly
2N/A * or kDNSServiceInterfaceIndexAny.
2N/A * If a client has a 'private' service, accessible only to other processes
2N/A * running on the same machine, this allows the client to advertise that service
2N/A * in a way such that it does not inadvertently appear in service lists on
2N/A * all the other machines on the network.
2N/A *
2N/A * If the client passes kDNSServiceInterfaceIndexLocalOnly when browsing
2N/A * then it will find *all* records registered on that same local machine.
2N/A * Clients explicitly wishing to discover *only* LocalOnly services can
2N/A * accomplish this by inspecting the interfaceIndex of each service reported
2N/A * to their DNSServiceBrowseReply() callback function, and discarding those
2N/A * where the interface index is not kDNSServiceInterfaceIndexLocalOnly.
2N/A */
2N/A
2N/A#define kDNSServiceInterfaceIndexAny 0
2N/A#define kDNSServiceInterfaceIndexLocalOnly ( (uint32_t) -1 )
2N/A
2N/A
2N/Atypedef uint32_t DNSServiceFlags;
2N/Atypedef int32_t DNSServiceErrorType;
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A
2N/A/* DNSServiceRefSockFD()
2N/A *
2N/A * Access underlying Unix domain socket for an initialized DNSServiceRef.
2N/A * The DNS Service Discovery implmementation uses this socket to communicate between
2N/A * the client and the mDNSResponder daemon. The application MUST NOT directly read from
2N/A * or write to this socket. Access to the socket is provided so that it can be used as a
2N/A * run loop source, or in a select() loop: when data is available for reading on the socket,
2N/A * DNSServiceProcessResult() should be called, which will extract the daemon's reply from
2N/A * the socket, and pass it to the appropriate application callback. By using a run loop or
2N/A * select(), results from the daemon can be processed asynchronously. Without using these
2N/A * constructs, DNSServiceProcessResult() will block until the response from the daemon arrives.
2N/A * The client is responsible for ensuring that the data on the socket is processed in a timely
2N/A * fashion - the daemon may terminate its connection with a client that does not clear its
2N/A * socket buffer.
2N/A *
2N/A * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
2N/A *
2N/A * return value: The DNSServiceRef's underlying socket descriptor, or -1 on
2N/A * error.
2N/A */
2N/A
2N/Aint DNSSD_API DNSServiceRefSockFD(DNSServiceRef sdRef);
2N/A
2N/A
2N/A/* DNSServiceProcessResult()
2N/A *
2N/A * Read a reply from the daemon, calling the appropriate application callback. This call will
2N/A * block until the daemon's response is received. Use DNSServiceRefSockFD() in
2N/A * conjunction with a run loop or select() to determine the presence of a response from the
2N/A * server before calling this function to process the reply without blocking. Call this function
2N/A * at any point if it is acceptable to block until the daemon's response arrives. Note that the
2N/A * client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is
2N/A * a reply from the daemon - the daemon may terminate its connection with a client that does not
2N/A * process the daemon's responses.
2N/A *
2N/A * sdRef: A DNSServiceRef initialized by any of the DNSService calls
2N/A * that take a callback parameter.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
2N/A * an error code indicating the specific failure that occurred.
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdRef);
2N/A
2N/A
2N/A/* DNSServiceRefDeallocate()
2N/A *
2N/A * Terminate a connection with the daemon and free memory associated with the DNSServiceRef.
2N/A * Any services or records registered with this DNSServiceRef will be deregistered. Any
2N/A * Browse, Resolve, or Query operations called with this reference will be terminated.
2N/A *
2N/A * Note: If the reference's underlying socket is used in a run loop or select() call, it should
2N/A * be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's
2N/A * socket.
2N/A *
2N/A * Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs
2N/A * created via this reference will be invalidated by this call - the resource records are
2N/A * deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly,
2N/A * if the reference was initialized with DNSServiceRegister, and an extra resource record was
2N/A * added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call
2N/A * is invalidated when this function is called - the DNSRecordRef may not be used in subsequent
2N/A * functions.
2N/A *
2N/A * Note: This call is to be used only with the DNSServiceRef defined by this API. It is
2N/A * not compatible with dns_service_discovery_ref objects defined in the legacy Mach-based
2N/A * DNSServiceDiscovery.h API.
2N/A *
2N/A * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
2N/A *
2N/A */
2N/A
2N/Avoid DNSSD_API DNSServiceRefDeallocate(DNSServiceRef sdRef);
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * Domain Enumeration
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A/* DNSServiceEnumerateDomains()
2N/A *
2N/A * Asynchronously enumerate domains available for browsing and registration.
2N/A *
2N/A * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
2N/A * are to be found.
2N/A *
2N/A * Note that the names returned are (like all of DNS-SD) UTF-8 strings,
2N/A * and are escaped using standard DNS escaping rules.
2N/A * (See "Notes on DNS Name Escaping" earlier in this file for more details.)
2N/A * A graphical browser displaying a hierarchical tree-structured view should cut
2N/A * the names at the bare dots to yield individual labels, then de-escape each
2N/A * label according to the escaping rules, and then display the resulting UTF-8 text.
2N/A *
2N/A * DNSServiceDomainEnumReply Callback Parameters:
2N/A *
2N/A * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
2N/A *
2N/A * flags: Possible values are:
2N/A * kDNSServiceFlagsMoreComing
2N/A * kDNSServiceFlagsAdd
2N/A * kDNSServiceFlagsDefault
2N/A *
2N/A * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
2N/A * interface is determined via the if_nametoindex() family of calls.)
2N/A *
2N/A * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise indicates
2N/A * the failure that occurred (other parameters are undefined if errorCode is nonzero).
2N/A *
2N/A * replyDomain: The name of the domain.
2N/A *
2N/A * context: The context pointer passed to DNSServiceEnumerateDomains.
2N/A *
2N/A */
2N/A
2N/Atypedef void (DNSSD_API *DNSServiceDomainEnumReply)
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A DNSServiceErrorType errorCode,
2N/A const char *replyDomain,
2N/A void *context
2N/A );
2N/A
2N/A
2N/A/* DNSServiceEnumerateDomains() Parameters:
2N/A *
2N/A *
2N/A * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
2N/A * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
2N/A * and the enumeration operation will run indefinitely until the client
2N/A * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
2N/A *
2N/A * flags: Possible values are:
2N/A * kDNSServiceFlagsBrowseDomains to enumerate domains recommended for browsing.
2N/A * kDNSServiceFlagsRegistrationDomains to enumerate domains recommended
2N/A * for registration.
2N/A *
2N/A * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
2N/A * (the index for a given interface is determined via the if_nametoindex()
2N/A * family of calls.) Most applications will pass 0 to enumerate domains on
2N/A * all interfaces. See "Constants for specifying an interface index" for more details.
2N/A *
2N/A * callBack: The function to be called when a domain is found or the call asynchronously
2N/A * fails.
2N/A *
2N/A * context: An application context pointer which is passed to the callback function
2N/A * (may be NULL).
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
2N/A * errors are delivered to the callback), otherwise returns an error code indicating
2N/A * the error that occurred (the callback is not invoked and the DNSServiceRef
2N/A * is not initialized.)
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains
2N/A (
2N/A DNSServiceRef *sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A DNSServiceDomainEnumReply callBack,
2N/A void *context /* may be NULL */
2N/A );
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * Service Registration
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A/* Register a service that is discovered via Browse() and Resolve() calls.
2N/A *
2N/A *
2N/A * DNSServiceRegisterReply() Callback Parameters:
2N/A *
2N/A * sdRef: The DNSServiceRef initialized by DNSServiceRegister().
2N/A *
2N/A * flags: Currently unused, reserved for future use.
2N/A *
2N/A * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
2N/A * indicate the failure that occurred (including name conflicts,
2N/A * if the kDNSServiceFlagsNoAutoRename flag was used when registering.)
2N/A * Other parameters are undefined if errorCode is nonzero.
2N/A *
2N/A * name: The service name registered (if the application did not specify a name in
2N/A * DNSServiceRegister(), this indicates what name was automatically chosen).
2N/A *
2N/A * regtype: The type of service registered, as it was passed to the callout.
2N/A *
2N/A * domain: The domain on which the service was registered (if the application did not
2N/A * specify a domain in DNSServiceRegister(), this indicates the default domain
2N/A * on which the service was registered).
2N/A *
2N/A * context: The context pointer that was passed to the callout.
2N/A *
2N/A */
2N/A
2N/Atypedef void (DNSSD_API *DNSServiceRegisterReply)
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSServiceFlags flags,
2N/A DNSServiceErrorType errorCode,
2N/A const char *name,
2N/A const char *regtype,
2N/A const char *domain,
2N/A void *context
2N/A );
2N/A
2N/A
2N/A/* DNSServiceRegister() Parameters:
2N/A *
2N/A * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
2N/A * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
2N/A * and the registration will remain active indefinitely until the client
2N/A * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
2N/A *
2N/A * interfaceIndex: If non-zero, specifies the interface on which to register the service
2N/A * (the index for a given interface is determined via the if_nametoindex()
2N/A * family of calls.) Most applications will pass 0 to register on all
2N/A * available interfaces. See "Constants for specifying an interface index" for more details.
2N/A *
2N/A * flags: Indicates the renaming behavior on name conflict (most applications
2N/A * will pass 0). See flag definitions above for details.
2N/A *
2N/A * name: If non-NULL, specifies the service name to be registered.
2N/A * Most applications will not specify a name, in which case the computer
2N/A * name is used (this name is communicated to the client via the callback).
2N/A * If a name is specified, it must be 1-63 bytes of UTF-8 text.
2N/A * If the name is longer than 63 bytes it will be automatically truncated
2N/A * to a legal length, unless the NoAutoRename flag is set,
2N/A * in which case kDNSServiceErr_BadParam will be returned.
2N/A *
2N/A * regtype: The service type followed by the protocol, separated by a dot
2N/A * (e.g. "_ftp._tcp"). The service type must be an underscore, followed
2N/A * by 1-14 characters, which may be letters, digits, or hyphens.
2N/A * The transport protocol must be "_tcp" or "_udp". New service types
2N/A * should be registered at <http://www.dns-sd.org/ServiceTypes.html>.
2N/A *
2N/A * domain: If non-NULL, specifies the domain on which to advertise the service.
2N/A * Most applications will not specify a domain, instead automatically
2N/A * registering in the default domain(s).
2N/A *
2N/A * host: If non-NULL, specifies the SRV target host name. Most applications
2N/A * will not specify a host, instead automatically using the machine's
2N/A * default host name(s). Note that specifying a non-NULL host does NOT
2N/A * create an address record for that host - the application is responsible
2N/A * for ensuring that the appropriate address record exists, or creating it
2N/A * via DNSServiceRegisterRecord().
2N/A *
2N/A * port: The port, in network byte order, on which the service accepts connections.
2N/A * Pass 0 for a "placeholder" service (i.e. a service that will not be discovered
2N/A * by browsing, but will cause a name conflict if another client tries to
2N/A * register that same name). Most clients will not use placeholder services.
2N/A *
2N/A * txtLen: The length of the txtRecord, in bytes. Must be zero if the txtRecord is NULL.
2N/A *
2N/A * txtRecord: The TXT record rdata. A non-NULL txtRecord MUST be a properly formatted DNS
2N/A * TXT record, i.e. <length byte> <data> <length byte> <data> ...
2N/A * Passing NULL for the txtRecord is allowed as a synonym for txtLen=1, txtRecord="",
2N/A * i.e. it creates a TXT record of length one containing a single empty string.
2N/A * RFC 1035 doesn't allow a TXT record to contain *zero* strings, so a single empty
2N/A * string is the smallest legal DNS TXT record.
2N/A * As with the other parameters, the DNSServiceRegister call copies the txtRecord
2N/A * data; e.g. if you allocated the storage for the txtRecord parameter with malloc()
2N/A * then you can safely free that memory right after the DNSServiceRegister call returns.
2N/A *
2N/A * callBack: The function to be called when the registration completes or asynchronously
2N/A * fails. The client MAY pass NULL for the callback - The client will NOT be notified
2N/A * of the default values picked on its behalf, and the client will NOT be notified of any
2N/A * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
2N/A * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
2N/A * The client may still deregister the service at any time via DNSServiceRefDeallocate().
2N/A *
2N/A * context: An application context pointer which is passed to the callback function
2N/A * (may be NULL).
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
2N/A * errors are delivered to the callback), otherwise returns an error code indicating
2N/A * the error that occurred (the callback is never invoked and the DNSServiceRef
2N/A * is not initialized.)
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceRegister
2N/A (
2N/A DNSServiceRef *sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A const char *name, /* may be NULL */
2N/A const char *regtype,
2N/A const char *domain, /* may be NULL */
2N/A const char *host, /* may be NULL */
2N/A uint16_t port,
2N/A uint16_t txtLen,
2N/A const void *txtRecord, /* may be NULL */
2N/A DNSServiceRegisterReply callBack, /* may be NULL */
2N/A void *context /* may be NULL */
2N/A );
2N/A
2N/A
2N/A/* DNSServiceAddRecord()
2N/A *
2N/A * Add a record to a registered service. The name of the record will be the same as the
2N/A * registered service's name.
2N/A * The record can later be updated or deregistered by passing the RecordRef initialized
2N/A * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
2N/A *
2N/A * Note that the DNSServiceAddRecord/UpdateRecord/RemoveRecord are *NOT* thread-safe
2N/A * with respect to a single DNSServiceRef. If you plan to have multiple threads
2N/A * in your program simultaneously add, update, or remove records from the same
2N/A * DNSServiceRef, then it's the caller's responsibility to use a mutext lock
2N/A * or take similar appropriate precautions to serialize those calls.
2N/A *
2N/A *
2N/A * Parameters;
2N/A *
2N/A * sdRef: A DNSServiceRef initialized by DNSServiceRegister().
2N/A *
2N/A * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
2N/A * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
2N/A * If the above DNSServiceRef is passed to DNSServiceRefDeallocate(), RecordRef is also
2N/A * invalidated and may not be used further.
2N/A *
2N/A * flags: Currently ignored, reserved for future use.
2N/A *
2N/A * rrtype: The type of the record (e.g. kDNSServiceType_TXT, kDNSServiceType_SRV, etc)
2N/A *
2N/A * rdlen: The length, in bytes, of the rdata.
2N/A *
2N/A * rdata: The raw rdata to be contained in the added resource record.
2N/A *
2N/A * ttl: The time to live of the resource record, in seconds. Pass 0 to use a default value.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
2N/A * error code indicating the error that occurred (the RecordRef is not initialized).
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceAddRecord
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSRecordRef *RecordRef,
2N/A DNSServiceFlags flags,
2N/A uint16_t rrtype,
2N/A uint16_t rdlen,
2N/A const void *rdata,
2N/A uint32_t ttl
2N/A );
2N/A
2N/A
2N/A/* DNSServiceUpdateRecord
2N/A *
2N/A * Update a registered resource record. The record must either be:
2N/A * - The primary txt record of a service registered via DNSServiceRegister()
2N/A * - A record added to a registered service via DNSServiceAddRecord()
2N/A * - An individual record registered by DNSServiceRegisterRecord()
2N/A *
2N/A *
2N/A * Parameters:
2N/A *
2N/A * sdRef: A DNSServiceRef that was initialized by DNSServiceRegister()
2N/A * or DNSServiceCreateConnection().
2N/A *
2N/A * RecordRef: A DNSRecordRef initialized by DNSServiceAddRecord, or NULL to update the
2N/A * service's primary txt record.
2N/A *
2N/A * flags: Currently ignored, reserved for future use.
2N/A *
2N/A * rdlen: The length, in bytes, of the new rdata.
2N/A *
2N/A * rdata: The new rdata to be contained in the updated resource record.
2N/A *
2N/A * ttl: The time to live of the updated resource record, in seconds.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
2N/A * error code indicating the error that occurred.
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceUpdateRecord
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSRecordRef RecordRef, /* may be NULL */
2N/A DNSServiceFlags flags,
2N/A uint16_t rdlen,
2N/A const void *rdata,
2N/A uint32_t ttl
2N/A );
2N/A
2N/A
2N/A/* DNSServiceRemoveRecord
2N/A *
2N/A * Remove a record previously added to a service record set via DNSServiceAddRecord(), or deregister
2N/A * an record registered individually via DNSServiceRegisterRecord().
2N/A *
2N/A * Parameters:
2N/A *
2N/A * sdRef: A DNSServiceRef initialized by DNSServiceRegister() (if the
2N/A * record being removed was registered via DNSServiceAddRecord()) or by
2N/A * DNSServiceCreateConnection() (if the record being removed was registered via
2N/A * DNSServiceRegisterRecord()).
2N/A *
2N/A * recordRef: A DNSRecordRef initialized by a successful call to DNSServiceAddRecord()
2N/A * or DNSServiceRegisterRecord().
2N/A *
2N/A * flags: Currently ignored, reserved for future use.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
2N/A * error code indicating the error that occurred.
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceRemoveRecord
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSRecordRef RecordRef,
2N/A DNSServiceFlags flags
2N/A );
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * Service Discovery
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A/* Browse for instances of a service.
2N/A *
2N/A *
2N/A * DNSServiceBrowseReply() Parameters:
2N/A *
2N/A * sdRef: The DNSServiceRef initialized by DNSServiceBrowse().
2N/A *
2N/A * flags: Possible values are kDNSServiceFlagsMoreComing and kDNSServiceFlagsAdd.
2N/A * See flag definitions for details.
2N/A *
2N/A * interfaceIndex: The interface on which the service is advertised. This index should
2N/A * be passed to DNSServiceResolve() when resolving the service.
2N/A *
2N/A * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
2N/A * indicate the failure that occurred. Other parameters are undefined if
2N/A * the errorCode is nonzero.
2N/A *
2N/A * serviceName: The discovered service name. This name should be displayed to the user,
2N/A * and stored for subsequent use in the DNSServiceResolve() call.
2N/A *
2N/A * regtype: The service type, which is usually (but not always) the same as was passed
2N/A * to DNSServiceBrowse(). One case where the discovered service type may
2N/A * not be the same as the requested service type is when using subtypes:
2N/A * The client may want to browse for only those ftp servers that allow
2N/A * anonymous connections. The client will pass the string "_ftp._tcp,_anon"
2N/A * to DNSServiceBrowse(), but the type of the service that's discovered
2N/A * is simply "_ftp._tcp". The regtype for each discovered service instance
2N/A * should be stored along with the name, so that it can be passed to
2N/A * DNSServiceResolve() when the service is later resolved.
2N/A *
2N/A * domain: The domain of the discovered service instance. This may or may not be the
2N/A * same as the domain that was passed to DNSServiceBrowse(). The domain for each
2N/A * discovered service instance should be stored along with the name, so that
2N/A * it can be passed to DNSServiceResolve() when the service is later resolved.
2N/A *
2N/A * context: The context pointer that was passed to the callout.
2N/A *
2N/A */
2N/A
2N/Atypedef void (DNSSD_API *DNSServiceBrowseReply)
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A DNSServiceErrorType errorCode,
2N/A const char *serviceName,
2N/A const char *regtype,
2N/A const char *replyDomain,
2N/A void *context
2N/A );
2N/A
2N/A
2N/A/* DNSServiceBrowse() Parameters:
2N/A *
2N/A * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
2N/A * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
2N/A * and the browse operation will run indefinitely until the client
2N/A * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
2N/A *
2N/A * flags: Currently ignored, reserved for future use.
2N/A *
2N/A * interfaceIndex: If non-zero, specifies the interface on which to browse for services
2N/A * (the index for a given interface is determined via the if_nametoindex()
2N/A * family of calls.) Most applications will pass 0 to browse on all available
2N/A * interfaces. See "Constants for specifying an interface index" for more details.
2N/A *
2N/A * regtype: The service type being browsed for followed by the protocol, separated by a
2N/A * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
2N/A *
2N/A * domain: If non-NULL, specifies the domain on which to browse for services.
2N/A * Most applications will not specify a domain, instead browsing on the
2N/A * default domain(s).
2N/A *
2N/A * callBack: The function to be called when an instance of the service being browsed for
2N/A * is found, or if the call asynchronously fails.
2N/A *
2N/A * context: An application context pointer which is passed to the callback function
2N/A * (may be NULL).
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
2N/A * errors are delivered to the callback), otherwise returns an error code indicating
2N/A * the error that occurred (the callback is not invoked and the DNSServiceRef
2N/A * is not initialized.)
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceBrowse
2N/A (
2N/A DNSServiceRef *sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A const char *regtype,
2N/A const char *domain, /* may be NULL */
2N/A DNSServiceBrowseReply callBack,
2N/A void *context /* may be NULL */
2N/A );
2N/A
2N/A
2N/A/* DNSServiceResolve()
2N/A *
2N/A * Resolve a service name discovered via DNSServiceBrowse() to a target host name, port number, and
2N/A * txt record.
2N/A *
2N/A * Note: Applications should NOT use DNSServiceResolve() solely for txt record monitoring - use
2N/A * DNSServiceQueryRecord() instead, as it is more efficient for this task.
2N/A *
2N/A * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
2N/A * DNSServiceRefDeallocate().
2N/A *
2N/A * Note: DNSServiceResolve() behaves correctly for typical services that have a single SRV record
2N/A * and a single TXT record. To resolve non-standard services with multiple SRV or TXT records,
2N/A * DNSServiceQueryRecord() should be used.
2N/A *
2N/A * DNSServiceResolveReply Callback Parameters:
2N/A *
2N/A * sdRef: The DNSServiceRef initialized by DNSServiceResolve().
2N/A *
2N/A * flags: Currently unused, reserved for future use.
2N/A *
2N/A * interfaceIndex: The interface on which the service was resolved.
2N/A *
2N/A * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
2N/A * indicate the failure that occurred. Other parameters are undefined if
2N/A * the errorCode is nonzero.
2N/A *
2N/A * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
2N/A * (This name is escaped following standard DNS rules, making it suitable for
2N/A * passing to standard system DNS APIs such as res_query(), or to the
2N/A * special-purpose functions included in this API that take fullname parameters.
2N/A * See "Notes on DNS Name Escaping" earlier in this file for more details.)
2N/A *
2N/A * hosttarget: The target hostname of the machine providing the service. This name can
2N/A * be passed to functions like gethostbyname() to identify the host's IP address.
2N/A *
2N/A * port: The port, in network byte order, on which connections are accepted for this service.
2N/A *
2N/A * txtLen: The length of the txt record, in bytes.
2N/A *
2N/A * txtRecord: The service's primary txt record, in standard txt record format.
2N/A *
2N/A * context: The context pointer that was passed to the callout.
2N/A *
2N/A * NOTE: In earlier versions of this header file, the txtRecord parameter was declared "const char *"
2N/A * This is incorrect, since it contains length bytes which are values in the range 0 to 255, not -128 to +127.
2N/A * Depending on your compiler settings, this change may cause signed/unsigned mismatch warnings.
2N/A * These should be fixed by updating your own callback function definition to match the corrected
2N/A * function signature using "const unsigned char *txtRecord". Making this change may also fix inadvertent
2N/A * bugs in your callback function, where it could have incorrectly interpreted a length byte with value 250
2N/A * as being -6 instead, with various bad consequences ranging from incorrect operation to software crashes.
2N/A * If you need to maintain portable code that will compile cleanly with both the old and new versions of
2N/A * this header file, you should update your callback function definition to use the correct unsigned value,
2N/A * and then in the place where you pass your callback function to DNSServiceResolve(), use a cast to eliminate
2N/A * the compiler warning, e.g.:
2N/A * DNSServiceResolve(sd, flags, index, name, regtype, domain, (DNSServiceResolveReply)MyCallback, context);
2N/A * This will ensure that your code compiles cleanly without warnings (and more importantly, works correctly)
2N/A * with both the old header and with the new corrected version.
2N/A *
2N/A */
2N/A
2N/Atypedef void (DNSSD_API *DNSServiceResolveReply)
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A DNSServiceErrorType errorCode,
2N/A const char *fullname,
2N/A const char *hosttarget,
2N/A uint16_t port,
2N/A uint16_t txtLen,
2N/A const unsigned char *txtRecord,
2N/A void *context
2N/A );
2N/A
2N/A
2N/A/* DNSServiceResolve() Parameters
2N/A *
2N/A * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
2N/A * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
2N/A * and the resolve operation will run indefinitely until the client
2N/A * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
2N/A *
2N/A * flags: Currently ignored, reserved for future use.
2N/A *
2N/A * interfaceIndex: The interface on which to resolve the service. If this resolve call is
2N/A * as a result of a currently active DNSServiceBrowse() operation, then the
2N/A * interfaceIndex should be the index reported in the DNSServiceBrowseReply
2N/A * callback. If this resolve call is using information previously saved
2N/A * (e.g. in a preference file) for later use, then use interfaceIndex 0, because
2N/A * the desired service may now be reachable via a different physical interface.
2N/A * See "Constants for specifying an interface index" for more details.
2N/A *
2N/A * name: The name of the service instance to be resolved, as reported to the
2N/A * DNSServiceBrowseReply() callback.
2N/A *
2N/A * regtype: The type of the service instance to be resolved, as reported to the
2N/A * DNSServiceBrowseReply() callback.
2N/A *
2N/A * domain: The domain of the service instance to be resolved, as reported to the
2N/A * DNSServiceBrowseReply() callback.
2N/A *
2N/A * callBack: The function to be called when a result is found, or if the call
2N/A * asynchronously fails.
2N/A *
2N/A * context: An application context pointer which is passed to the callback function
2N/A * (may be NULL).
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
2N/A * errors are delivered to the callback), otherwise returns an error code indicating
2N/A * the error that occurred (the callback is never invoked and the DNSServiceRef
2N/A * is not initialized.)
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceResolve
2N/A (
2N/A DNSServiceRef *sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A const char *name,
2N/A const char *regtype,
2N/A const char *domain,
2N/A DNSServiceResolveReply callBack,
2N/A void *context /* may be NULL */
2N/A );
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * Special Purpose Calls (most applications will not use these)
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A/* DNSServiceCreateConnection()
2N/A *
2N/A * Create a connection to the daemon allowing efficient registration of
2N/A * multiple individual records.
2N/A *
2N/A *
2N/A * Parameters:
2N/A *
2N/A * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating
2N/A * the reference (via DNSServiceRefDeallocate()) severs the
2N/A * connection and deregisters all records registered on this connection.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
2N/A * an error code indicating the specific failure that occurred (in which
2N/A * case the DNSServiceRef is not initialized).
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceCreateConnection(DNSServiceRef *sdRef);
2N/A
2N/A
2N/A/* DNSServiceRegisterRecord
2N/A *
2N/A * Register an individual resource record on a connected DNSServiceRef.
2N/A *
2N/A * Note that name conflicts occurring for records registered via this call must be handled
2N/A * by the client in the callback.
2N/A *
2N/A *
2N/A * DNSServiceRegisterRecordReply() parameters:
2N/A *
2N/A * sdRef: The connected DNSServiceRef initialized by
2N/A * DNSServiceCreateConnection().
2N/A *
2N/A * RecordRef: The DNSRecordRef initialized by DNSServiceRegisterRecord(). If the above
2N/A * DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is
2N/A * invalidated, and may not be used further.
2N/A *
2N/A * flags: Currently unused, reserved for future use.
2N/A *
2N/A * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
2N/A * indicate the failure that occurred (including name conflicts.)
2N/A * Other parameters are undefined if errorCode is nonzero.
2N/A *
2N/A * context: The context pointer that was passed to the callout.
2N/A *
2N/A */
2N/A
2N/A typedef void (DNSSD_API *DNSServiceRegisterRecordReply)
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSRecordRef RecordRef,
2N/A DNSServiceFlags flags,
2N/A DNSServiceErrorType errorCode,
2N/A void *context
2N/A );
2N/A
2N/A
2N/A/* DNSServiceRegisterRecord() Parameters:
2N/A *
2N/A * sdRef: A DNSServiceRef initialized by DNSServiceCreateConnection().
2N/A *
2N/A * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
2N/A * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
2N/A * (To deregister ALL records registered on a single connected DNSServiceRef
2N/A * and deallocate each of their corresponding DNSServiceRecordRefs, call
2N/A * DNSServiceRefDealloocate()).
2N/A *
2N/A * flags: Possible values are kDNSServiceFlagsShared or kDNSServiceFlagsUnique
2N/A * (see flag type definitions for details).
2N/A *
2N/A * interfaceIndex: If non-zero, specifies the interface on which to register the record
2N/A * (the index for a given interface is determined via the if_nametoindex()
2N/A * family of calls.) Passing 0 causes the record to be registered on all interfaces.
2N/A * See "Constants for specifying an interface index" for more details.
2N/A *
2N/A * fullname: The full domain name of the resource record.
2N/A *
2N/A * rrtype: The numerical type of the resource record (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
2N/A *
2N/A * rrclass: The class of the resource record (usually kDNSServiceClass_IN)
2N/A *
2N/A * rdlen: Length, in bytes, of the rdata.
2N/A *
2N/A * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
2N/A *
2N/A * ttl: The time to live of the resource record, in seconds. Pass 0 to use a default value.
2N/A *
2N/A * callBack: The function to be called when a result is found, or if the call
2N/A * asynchronously fails (e.g. because of a name conflict.)
2N/A *
2N/A * context: An application context pointer which is passed to the callback function
2N/A * (may be NULL).
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
2N/A * errors are delivered to the callback), otherwise returns an error code indicating
2N/A * the error that occurred (the callback is never invoked and the DNSRecordRef is
2N/A * not initialized.)
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceRegisterRecord
2N/A (
2N/A DNSServiceRef sdRef,
2N/A DNSRecordRef *RecordRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A const char *fullname,
2N/A uint16_t rrtype,
2N/A uint16_t rrclass,
2N/A uint16_t rdlen,
2N/A const void *rdata,
2N/A uint32_t ttl,
2N/A DNSServiceRegisterRecordReply callBack,
2N/A void *context /* may be NULL */
2N/A );
2N/A
2N/A
2N/A/* DNSServiceQueryRecord
2N/A *
2N/A * Query for an arbitrary DNS record.
2N/A *
2N/A *
2N/A * DNSServiceQueryRecordReply() Callback Parameters:
2N/A *
2N/A * sdRef: The DNSServiceRef initialized by DNSServiceQueryRecord().
2N/A *
2N/A * flags: Possible values are kDNSServiceFlagsMoreComing and
2N/A * kDNSServiceFlagsAdd. The Add flag is NOT set for PTR records
2N/A * with a ttl of 0, i.e. "Remove" events.
2N/A *
2N/A * interfaceIndex: The interface on which the query was resolved (the index for a given
2N/A * interface is determined via the if_nametoindex() family of calls).
2N/A * See "Constants for specifying an interface index" for more details.
2N/A *
2N/A * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
2N/A * indicate the failure that occurred. Other parameters are undefined if
2N/A * errorCode is nonzero.
2N/A *
2N/A * fullname: The resource record's full domain name.
2N/A *
2N/A * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
2N/A *
2N/A * rrclass: The class of the resource record (usually kDNSServiceClass_IN).
2N/A *
2N/A * rdlen: The length, in bytes, of the resource record rdata.
2N/A *
2N/A * rdata: The raw rdata of the resource record.
2N/A *
2N/A * ttl: The resource record's time to live, in seconds.
2N/A *
2N/A * context: The context pointer that was passed to the callout.
2N/A *
2N/A */
2N/A
2N/Atypedef void (DNSSD_API *DNSServiceQueryRecordReply)
2N/A (
2N/A DNSServiceRef DNSServiceRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A DNSServiceErrorType errorCode,
2N/A const char *fullname,
2N/A uint16_t rrtype,
2N/A uint16_t rrclass,
2N/A uint16_t rdlen,
2N/A const void *rdata,
2N/A uint32_t ttl,
2N/A void *context
2N/A );
2N/A
2N/A
2N/A/* DNSServiceQueryRecord() Parameters:
2N/A *
2N/A * sdRef: A pointer to an uninitialized DNSServiceRef. If the call succeeds
2N/A * then it initializes the DNSServiceRef, returns kDNSServiceErr_NoError,
2N/A * and the query operation will run indefinitely until the client
2N/A * terminates it by passing this DNSServiceRef to DNSServiceRefDeallocate().
2N/A *
2N/A * flags: Pass kDNSServiceFlagsLongLivedQuery to create a "long-lived" unicast
2N/A * query in a non-local domain. Without setting this flag, unicast queries
2N/A * will be one-shot - that is, only answers available at the time of the call
2N/A * will be returned. By setting this flag, answers (including Add and Remove
2N/A * events) that become available after the initial call is made will generate
2N/A * callbacks. This flag has no effect on link-local multicast queries.
2N/A *
2N/A * interfaceIndex: If non-zero, specifies the interface on which to issue the query
2N/A * (the index for a given interface is determined via the if_nametoindex()
2N/A * family of calls.) Passing 0 causes the name to be queried for on all
2N/A * interfaces. See "Constants for specifying an interface index" for more details.
2N/A *
2N/A * fullname: The full domain name of the resource record to be queried for.
2N/A *
2N/A * rrtype: The numerical type of the resource record to be queried for
2N/A * (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
2N/A *
2N/A * rrclass: The class of the resource record (usually kDNSServiceClass_IN).
2N/A *
2N/A * callBack: The function to be called when a result is found, or if the call
2N/A * asynchronously fails.
2N/A *
2N/A * context: An application context pointer which is passed to the callback function
2N/A * (may be NULL).
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
2N/A * errors are delivered to the callback), otherwise returns an error code indicating
2N/A * the error that occurred (the callback is never invoked and the DNSServiceRef
2N/A * is not initialized.)
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceQueryRecord
2N/A (
2N/A DNSServiceRef *sdRef,
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A const char *fullname,
2N/A uint16_t rrtype,
2N/A uint16_t rrclass,
2N/A DNSServiceQueryRecordReply callBack,
2N/A void *context /* may be NULL */
2N/A );
2N/A
2N/A
2N/A/* DNSServiceReconfirmRecord
2N/A *
2N/A * Instruct the daemon to verify the validity of a resource record that appears to
2N/A * be out of date (e.g. because tcp connection to a service's target failed.)
2N/A * Causes the record to be flushed from the daemon's cache (as well as all other
2N/A * daemons' caches on the network) if the record is determined to be invalid.
2N/A *
2N/A * Parameters:
2N/A *
2N/A * flags: Currently unused, reserved for future use.
2N/A *
2N/A * interfaceIndex: If non-zero, specifies the interface of the record in question.
2N/A * Passing 0 causes all instances of this record to be reconfirmed.
2N/A *
2N/A * fullname: The resource record's full domain name.
2N/A *
2N/A * rrtype: The resource record's type (e.g. kDNSServiceType_PTR, kDNSServiceType_SRV, etc)
2N/A *
2N/A * rrclass: The class of the resource record (usually kDNSServiceClass_IN).
2N/A *
2N/A * rdlen: The length, in bytes, of the resource record rdata.
2N/A *
2N/A * rdata: The raw rdata of the resource record.
2N/A *
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord
2N/A (
2N/A DNSServiceFlags flags,
2N/A uint32_t interfaceIndex,
2N/A const char *fullname,
2N/A uint16_t rrtype,
2N/A uint16_t rrclass,
2N/A uint16_t rdlen,
2N/A const void *rdata
2N/A );
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * General Utility Functions
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A/* DNSServiceConstructFullName()
2N/A *
2N/A * Concatenate a three-part domain name (as returned by the above callbacks) into a
2N/A * properly-escaped full domain name. Note that callbacks in the above functions ALREADY ESCAPE
2N/A * strings where necessary.
2N/A *
2N/A * Parameters:
2N/A *
2N/A * fullName: A pointer to a buffer that where the resulting full domain name is to be written.
2N/A * The buffer must be kDNSServiceMaxDomainName (1005) bytes in length to
2N/A * accommodate the longest legal domain name without buffer overrun.
2N/A *
2N/A * service: The service name - any dots or backslashes must NOT be escaped.
2N/A * May be NULL (to construct a PTR record name, e.g.
2N/A * "_ftp._tcp.apple.com.").
2N/A *
2N/A * regtype: The service type followed by the protocol, separated by a dot
2N/A * (e.g. "_ftp._tcp").
2N/A *
2N/A * domain: The domain name, e.g. "apple.com.". Literal dots or backslashes,
2N/A * if any, must be escaped, e.g. "1st\. Floor.apple.com."
2N/A *
2N/A * return value: Returns 0 on success, -1 on error.
2N/A *
2N/A */
2N/A
2N/Aint DNSSD_API DNSServiceConstructFullName
2N/A (
2N/A char *fullName,
2N/A const char *service, /* may be NULL */
2N/A const char *regtype,
2N/A const char *domain
2N/A );
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * TXT Record Construction Functions
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A/*
2N/A * A typical calling sequence for TXT record construction is something like:
2N/A *
2N/A * Client allocates storage for TXTRecord data (e.g. declare buffer on the stack)
2N/A * TXTRecordCreate();
2N/A * TXTRecordSetValue();
2N/A * TXTRecordSetValue();
2N/A * TXTRecordSetValue();
2N/A * ...
2N/A * DNSServiceRegister( ... TXTRecordGetLength(), TXTRecordGetBytesPtr() ... );
2N/A * TXTRecordDeallocate();
2N/A * Explicitly deallocate storage for TXTRecord data (if not allocated on the stack)
2N/A */
2N/A
2N/A
2N/A/* TXTRecordRef
2N/A *
2N/A * Opaque internal data type.
2N/A * Note: Represents a DNS-SD TXT record.
2N/A */
2N/A
2N/Atypedef union _TXTRecordRef_t { char PrivateData[16]; char *ForceNaturalAlignment; } TXTRecordRef;
2N/A
2N/A
2N/A/* TXTRecordCreate()
2N/A *
2N/A * Creates a new empty TXTRecordRef referencing the specified storage.
2N/A *
2N/A * If the buffer parameter is NULL, or the specified storage size is not
2N/A * large enough to hold a key subsequently added using TXTRecordSetValue(),
2N/A * then additional memory will be added as needed using malloc().
2N/A *
2N/A * On some platforms, when memory is low, malloc() may fail. In this
2N/A * case, TXTRecordSetValue() will return kDNSServiceErr_NoMemory, and this
2N/A * error condition will need to be handled as appropriate by the caller.
2N/A *
2N/A * You can avoid the need to handle this error condition if you ensure
2N/A * that the storage you initially provide is large enough to hold all
2N/A * the key/value pairs that are to be added to the record.
2N/A * The caller can precompute the exact length required for all of the
2N/A * key/value pairs to be added, or simply provide a fixed-sized buffer
2N/A * known in advance to be large enough.
2N/A * A no-value (key-only) key requires (1 + key length) bytes.
2N/A * A key with empty value requires (1 + key length + 1) bytes.
2N/A * A key with non-empty value requires (1 + key length + 1 + value length).
2N/A * For most applications, DNS-SD TXT records are generally
2N/A * less than 100 bytes, so in most cases a simple fixed-sized
2N/A * 256-byte buffer will be more than sufficient.
2N/A * Recommended size limits for DNS-SD TXT Records are discussed in
2N/A * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
2N/A *
2N/A * Note: When passing parameters to and from these TXT record APIs,
2N/A * the key name does not include the '=' character. The '=' character
2N/A * is the separator between the key and value in the on-the-wire
2N/A * packet format; it is not part of either the key or the value.
2N/A *
2N/A * txtRecord: A pointer to an uninitialized TXTRecordRef.
2N/A *
2N/A * bufferLen: The size of the storage provided in the "buffer" parameter.
2N/A *
2N/A * buffer: Optional caller-supplied storage used to hold the TXTRecord data.
2N/A * This storage must remain valid for as long as
2N/A * the TXTRecordRef.
2N/A */
2N/A
2N/Avoid DNSSD_API TXTRecordCreate
2N/A (
2N/A TXTRecordRef *txtRecord,
2N/A uint16_t bufferLen,
2N/A void *buffer
2N/A );
2N/A
2N/A
2N/A/* TXTRecordDeallocate()
2N/A *
2N/A * Releases any resources allocated in the course of preparing a TXT Record
2N/A * using TXTRecordCreate()/TXTRecordSetValue()/TXTRecordRemoveValue().
2N/A * Ownership of the buffer provided in TXTRecordCreate() returns to the client.
2N/A *
2N/A * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
2N/A *
2N/A */
2N/A
2N/Avoid DNSSD_API TXTRecordDeallocate
2N/A (
2N/A TXTRecordRef *txtRecord
2N/A );
2N/A
2N/A
2N/A/* TXTRecordSetValue()
2N/A *
2N/A * Adds a key (optionally with value) to a TXTRecordRef. If the "key" already
2N/A * exists in the TXTRecordRef, then the current value will be replaced with
2N/A * the new value.
2N/A * Keys may exist in four states with respect to a given TXT record:
2N/A * - Absent (key does not appear at all)
2N/A * - Present with no value ("key" appears alone)
2N/A * - Present with empty value ("key=" appears in TXT record)
2N/A * - Present with non-empty value ("key=value" appears in TXT record)
2N/A * For more details refer to "Data Syntax for DNS-SD TXT Records" in
2N/A * <http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt>
2N/A *
2N/A * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
2N/A *
2N/A * key: A null-terminated string which only contains printable ASCII
2N/A * values (0x20-0x7E), excluding '=' (0x3D). Keys should be
2N/A * 8 characters or less (not counting the terminating null).
2N/A *
2N/A * valueSize: The size of the value.
2N/A *
2N/A * value: Any binary value. For values that represent
2N/A * textual data, UTF-8 is STRONGLY recommended.
2N/A * For values that represent textual data, valueSize
2N/A * should NOT include the terminating null (if any)
2N/A * at the end of the string.
2N/A * If NULL, then "key" will be added with no value.
2N/A * If non-NULL but valueSize is zero, then "key=" will be
2N/A * added with empty value.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success.
2N/A * Returns kDNSServiceErr_Invalid if the "key" string contains
2N/A * illegal characters.
2N/A * Returns kDNSServiceErr_NoMemory if adding this key would
2N/A * exceed the available storage.
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API TXTRecordSetValue
2N/A (
2N/A TXTRecordRef *txtRecord,
2N/A const char *key,
2N/A uint8_t valueSize, /* may be zero */
2N/A const void *value /* may be NULL */
2N/A );
2N/A
2N/A
2N/A/* TXTRecordRemoveValue()
2N/A *
2N/A * Removes a key from a TXTRecordRef. The "key" must be an
2N/A * ASCII string which exists in the TXTRecordRef.
2N/A *
2N/A * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
2N/A *
2N/A * key: A key name which exists in the TXTRecordRef.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success.
2N/A * Returns kDNSServiceErr_NoSuchKey if the "key" does not
2N/A * exist in the TXTRecordRef.
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API TXTRecordRemoveValue
2N/A (
2N/A TXTRecordRef *txtRecord,
2N/A const char *key
2N/A );
2N/A
2N/A
2N/A/* TXTRecordGetLength()
2N/A *
2N/A * Allows you to determine the length of the raw bytes within a TXTRecordRef.
2N/A *
2N/A * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
2N/A *
2N/A * return value: Returns the size of the raw bytes inside a TXTRecordRef
2N/A * which you can pass directly to DNSServiceRegister() or
2N/A * to DNSServiceUpdateRecord().
2N/A * Returns 0 if the TXTRecordRef is empty.
2N/A */
2N/A
2N/Auint16_t DNSSD_API TXTRecordGetLength
2N/A (
2N/A const TXTRecordRef *txtRecord
2N/A );
2N/A
2N/A
2N/A/* TXTRecordGetBytesPtr()
2N/A *
2N/A * Allows you to retrieve a pointer to the raw bytes within a TXTRecordRef.
2N/A *
2N/A * txtRecord: A TXTRecordRef initialized by calling TXTRecordCreate().
2N/A *
2N/A * return value: Returns a pointer to the raw bytes inside the TXTRecordRef
2N/A * which you can pass directly to DNSServiceRegister() or
2N/A * to DNSServiceUpdateRecord().
2N/A */
2N/A
2N/Aconst void * DNSSD_API TXTRecordGetBytesPtr
2N/A (
2N/A const TXTRecordRef *txtRecord
2N/A );
2N/A
2N/A
2N/A/*********************************************************************************************
2N/A *
2N/A * TXT Record Parsing Functions
2N/A *
2N/A *********************************************************************************************/
2N/A
2N/A/*
2N/A * A typical calling sequence for TXT record parsing is something like:
2N/A *
2N/A * Receive TXT record data in DNSServiceResolve() callback
2N/A * if (TXTRecordContainsKey(txtLen, txtRecord, "key")) then do something
2N/A * val1ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key1", &len1);
2N/A * val2ptr = TXTRecordGetValuePtr(txtLen, txtRecord, "key2", &len2);
2N/A * ...
2N/A * bcopy(val1ptr, myval1, len1);
2N/A * bcopy(val2ptr, myval2, len2);
2N/A * ...
2N/A * return;
2N/A *
2N/A * If you wish to retain the values after return from the DNSServiceResolve()
2N/A * callback, then you need to copy the data to your own storage using bcopy()
2N/A * or similar, as shown in the example above.
2N/A *
2N/A * If for some reason you need to parse a TXT record you built yourself
2N/A * using the TXT record construction functions above, then you can do
2N/A * that using TXTRecordGetLength and TXTRecordGetBytesPtr calls:
2N/A * TXTRecordGetValue(TXTRecordGetLength(x), TXTRecordGetBytesPtr(x), key, &len);
2N/A *
2N/A * Most applications only fetch keys they know about from a TXT record and
2N/A * ignore the rest.
2N/A * However, some debugging tools wish to fetch and display all keys.
2N/A * To do that, use the TXTRecordGetCount() and TXTRecordGetItemAtIndex() calls.
2N/A */
2N/A
2N/A/* TXTRecordContainsKey()
2N/A *
2N/A * Allows you to determine if a given TXT Record contains a specified key.
2N/A *
2N/A * txtLen: The size of the received TXT Record.
2N/A *
2N/A * txtRecord: Pointer to the received TXT Record bytes.
2N/A *
2N/A * key: A null-terminated ASCII string containing the key name.
2N/A *
2N/A * return value: Returns 1 if the TXT Record contains the specified key.
2N/A * Otherwise, it returns 0.
2N/A */
2N/A
2N/Aint DNSSD_API TXTRecordContainsKey
2N/A (
2N/A uint16_t txtLen,
2N/A const void *txtRecord,
2N/A const char *key
2N/A );
2N/A
2N/A
2N/A/* TXTRecordGetValuePtr()
2N/A *
2N/A * Allows you to retrieve the value for a given key from a TXT Record.
2N/A *
2N/A * txtLen: The size of the received TXT Record
2N/A *
2N/A * txtRecord: Pointer to the received TXT Record bytes.
2N/A *
2N/A * key: A null-terminated ASCII string containing the key name.
2N/A *
2N/A * valueLen: On output, will be set to the size of the "value" data.
2N/A *
2N/A * return value: Returns NULL if the key does not exist in this TXT record,
2N/A * or exists with no value (to differentiate between
2N/A * these two cases use TXTRecordContainsKey()).
2N/A * Returns pointer to location within TXT Record bytes
2N/A * if the key exists with empty or non-empty value.
2N/A * For empty value, valueLen will be zero.
2N/A * For non-empty value, valueLen will be length of value data.
2N/A */
2N/A
2N/Aconst void * DNSSD_API TXTRecordGetValuePtr
2N/A (
2N/A uint16_t txtLen,
2N/A const void *txtRecord,
2N/A const char *key,
2N/A uint8_t *valueLen
2N/A );
2N/A
2N/A
2N/A/* TXTRecordGetCount()
2N/A *
2N/A * Returns the number of keys stored in the TXT Record. The count
2N/A * can be used with TXTRecordGetItemAtIndex() to iterate through the keys.
2N/A *
2N/A * txtLen: The size of the received TXT Record.
2N/A *
2N/A * txtRecord: Pointer to the received TXT Record bytes.
2N/A *
2N/A * return value: Returns the total number of keys in the TXT Record.
2N/A *
2N/A */
2N/A
2N/Auint16_t DNSSD_API TXTRecordGetCount
2N/A (
2N/A uint16_t txtLen,
2N/A const void *txtRecord
2N/A );
2N/A
2N/A
2N/A/* TXTRecordGetItemAtIndex()
2N/A *
2N/A * Allows you to retrieve a key name and value pointer, given an index into
2N/A * a TXT Record. Legal index values range from zero to TXTRecordGetCount()-1.
2N/A * It's also possible to iterate through keys in a TXT record by simply
2N/A * calling TXTRecordGetItemAtIndex() repeatedly, beginning with index zero
2N/A * and increasing until TXTRecordGetItemAtIndex() returns kDNSServiceErr_Invalid.
2N/A *
2N/A * On return:
2N/A * For keys with no value, *value is set to NULL and *valueLen is zero.
2N/A * For keys with empty value, *value is non-NULL and *valueLen is zero.
2N/A * For keys with non-empty value, *value is non-NULL and *valueLen is non-zero.
2N/A *
2N/A * txtLen: The size of the received TXT Record.
2N/A *
2N/A * txtRecord: Pointer to the received TXT Record bytes.
2N/A *
2N/A * index: An index into the TXT Record.
2N/A *
2N/A * keyBufLen: The size of the string buffer being supplied.
2N/A *
2N/A * key: A string buffer used to store the key name.
2N/A * On return, the buffer contains a null-terminated C string
2N/A * giving the key name. DNS-SD TXT keys are usually
2N/A * 8 characters or less. To hold the maximum possible
2N/A * key name, the buffer should be 256 bytes long.
2N/A *
2N/A * valueLen: On output, will be set to the size of the "value" data.
2N/A *
2N/A * value: On output, *value is set to point to location within TXT
2N/A * Record bytes that holds the value data.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on success.
2N/A * Returns kDNSServiceErr_NoMemory if keyBufLen is too short.
2N/A * Returns kDNSServiceErr_Invalid if index is greater than
2N/A * TXTRecordGetCount()-1.
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex
2N/A (
2N/A uint16_t txtLen,
2N/A const void *txtRecord,
2N/A uint16_t index,
2N/A uint16_t keyBufLen,
2N/A char *key,
2N/A uint8_t *valueLen,
2N/A const void **value
2N/A );
2N/A
2N/A#ifdef __APPLE_API_PRIVATE
2N/A
2N/A/*
2N/A * Mac OS X specific functionality
2N/A * 3rd party clients of this API should not depend on future support or availability of this routine
2N/A */
2N/A
2N/A/* DNSServiceSetDefaultDomainForUser()
2N/A *
2N/A * Set the default domain for the caller's UID. Future browse and registration
2N/A * calls by this user that do not specify an explicit domain will browse and
2N/A * register in this wide-area domain in addition to .local. In addition, this
2N/A * domain will be returned as a Browse domain via domain enumeration calls.
2N/A *
2N/A *
2N/A * Parameters:
2N/A *
2N/A * flags: Pass kDNSServiceFlagsAdd to add a domain for a user. Call without
2N/A * this flag set to clear a previously added domain.
2N/A *
2N/A * domain: The domain to be used for the caller's UID.
2N/A *
2N/A * return value: Returns kDNSServiceErr_NoError on succeses, otherwise returns
2N/A * an error code indicating the error that occurred
2N/A */
2N/A
2N/ADNSServiceErrorType DNSSD_API DNSServiceSetDefaultDomainForUser
2N/A (
2N/A DNSServiceFlags flags,
2N/A const char *domain
2N/A );
2N/A
2N/A#endif //__APPLE_API_PRIVATE
2N/A
2N/A// Some C compiler cleverness. We can make the compiler check certain things for us,
2N/A// and report errors at compile-time if anything is wrong. The usual way to do this would
2N/A// be to use a run-time "if" statement or the conventional run-time "assert" mechanism, but
2N/A// then you don't find out what's wrong until you run the software. This way, if the assertion
2N/A// condition is false, the array size is negative, and the complier complains immediately.
2N/A
2N/Astruct DNS_SD_CompileTimeAssertionChecks
2N/A {
2N/A char assert0[(sizeof(union _TXTRecordRef_t) == 16) ? 1 : -1];
2N/A };
2N/A
2N/A#ifdef __cplusplus
2N/A }
2N/A#endif
2N/A
2N/A#endif /* _DNS_SD_H */