DNSSERVICEQUERYRECORD(3DNS_SD)DNSSERVICEQUERYRECORD(3DNS_SD)NAME
DNSServiceQueryRecord - query records from DNS
SYNOPSIS
cc [ flag ... ] file ... -ldns_sd [ library ... ]
#include <dns_sd.h>
DNSServiceErrorType DNSServiceQueryRecord(DNSServiceRef *sdRef,
DNSServiceFlags flags, uint32_t interfaceIndex, const char *fullname,
uint16_t rrtype, uint16_t rrclass,
DNSServiceServiceQueryRecordReply callBack, void *context);
typedef void(*DNSServiceQueryRecordReply)(DNSServiceRef DNSServiceRef,
DNSServiceFlags flags, uint32_t interfaceIndex,
DNSServiceErrorType errorCode, const char *fullname,
uint16_t rrtype, uint16_t rrclass, uint16_t rdlen,
const void *rdata, uint32_t ttl, void *context);
DESCRIPTION
The DNSServiceQueryRecord() function is used to query the daemon for
any DNS resource record type. The callback argument to DNSService‐
QueryRecord() points to a function of type DNSServiceQueryRecordReply()
listed above. The sdRef parameter in DNSServiceQueryRecord() points to
an uninitialized DNSServiceRef. The DNSServiceQueryRecord() function
returns kDNSServiceErr_NoError and initializes sdRef on success. The
query runs indefinitely until the client terminates by passing the ini‐
tialized sdRef from the query call to DNSServiceRefDeallocate().
The flag kDNSServiceFlagsLongLivedQuery should be passed in the flags
argument of DNSServiceQueryRecord() to create a "long-lived" unicast
query in a non-local domain. This flag has no effect on link local mul‐
ticast queries. Without this flag, unicast queries will be one-shot and
only the results that are available at the time of the query will be
returned. With long-lived queries, add or remove events that are avail‐
able after the first call generate callbacks. The interfaceIndex argu‐
ment specifies the interface on which to issue the query. Most applica‐
tions will pass a 0 as the interfaceIndex to make the query on all
interfaces. See the section "Constants for specifying an interface
index" in <dns_sd.h>. The fullname argument indicates the full domain
name of the resource record to be queried. The rrtype argument indi‐
cates the resource record type: kDNSServiceType_PTR, for example. The
rrclass argument holds the class of the resource record to be queried
(kDNSServiceClass_IN). The context argument can be NULL and points to a
value passed to the callback function.
The sdRef argument passed to the callback function is initialized by
the call to DNSServiceQueryRecord(). Possible values for the flags
parameter to the callback function are kDNSServiceFlagsMoreComing and
kDNSServiceFlagsAdd. The kDNSServiceFlagsMoreComing value is set to
indicate that additional results are immediately available. The
kDNSServiceFlagsAdd value indicates that the results returned to the
callback function are for a valid DNS record. If kDNSServiceFlagsAdd is
not set, the results returned are for a delete event. The errorCode
passed to the callback is kDNSServiceErr_NoError on success. Otherwise,
failure is indicated and other parameter values are undefined. The
fullname parameter indicates the full domain name of the resource
record . The rrtype indicates the resource record type. The rrclass
indicates the class of the DNS resource record. The rdlen parameter
indicates the length of the resource record rdata in bytes. The rdata
parameter points to raw rdata of the resource record. The ttl parameter
indicates the time to live of the resource record in seconds. The con‐
text parameter points to the value passed by the application in the
context argument to the DNSServiceQueryRecord() call.
RETURN VALUES
The DNSServiceQueryRecord function returns kDNSServiceErr_NoError on
success. Otherwise, an error code defined in <dns_sd.h> is returned to
indicate the specific failure that occurred.
ATTRIBUTES
See attributes(5) for description of the following attributes:
┌────────────────────┬─────────────────┐
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
├────────────────────┼─────────────────┤
│Interface Stability │ Committed │
├────────────────────┼─────────────────┤
│MT-Level │ Safe │
└────────────────────┴─────────────────┘
SEE ALSODNSServiceBrowse(3DNS_SD), DNSServiceRegister(3DNS_SD), DNSServiceRe‐
solve(3DNS_SD), attributes(5)
Aug 20, 2007 DNSSERVICEQUERYRECORD(3DNS_SD)