DNS Service Discovery Library Functions
DNSServiceQueryRecord(3DNS_SD)
NAME
DNSServiceQueryRecord - query records from DNS
SYNOPSIS
cc [ flag ... ] file ... -ldns_sd [ library ... ]
#include
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 argu-
ment to DNSServiceQueryRecord() points to a function of type
DNSServiceQueryRecordReply() listed above. The sdRef parame-
ter 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 pass-
ing the initialized sdRef from the query call to DNSServi-
ceRefDeallocate(). The flag kDNSServiceFlagsLongLivedQuery should be passed inthe flags argument of DNSServiceQueryRecord() to create a
"long-lived" unicast query in a non-local domain. This flag
has no effect on link local multicast queries. Without thisflag, unicast queries will be one-shot and only the results
that are available at the time of the query will bereturned. With long-lived queries, add or remove events that
are available after the first call generate callbacks. The interfaceIndex argument specifies the interface on which to issue the query. Most applications will pass a 0 as the interfaceIndex to make the query on all interfaces. See the section "Constants for specifying an interface index" in
. The fullname argument indicates the full domain name of the resource record to be queried. The rrtype argu-
ment indicates 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
SunOS 5.11 Last change: 20 Aug 2007 1
DNS Service Discovery Library FunctionsDNSServiceQueryRecord(3DNS_SD)
points to a value passed to the callback function.The sdRef argument passed to the callback function is ini-
tialized 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 thatadditional results are immediately available. The kDNSServi-
ceFlagsAdd value indicates that the results returned to thecallback function are for a valid DNS record. If kDNSServi-
ceFlagsAdd is not set, the results returned are for a delete event. The errorCode passed to the callback iskDNSServiceErr_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 pointsto raw rdata of the resource record. The ttl parameter indi-
cates the time to live of the resource record in seconds. The context parameter points to the value passed by theapplication in the context argument to the DNSService-
QueryRecord() call.RETURN VALUES
The DNSServiceQueryRecord function returns
kDNSServiceErr_NoError on success. Otherwise, an error code
defined in
failure that occurred.is returned to indicate the specific ATTRIBUTES
See attributes(5) for description of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Interface Stability | Committed ||_____________________________|_____________________________|
| MT-Level | Safe |
|_____________________________|_____________________________|
SEE ALSO
DNSServiceBrowse(3DNS_SD), DNSServiceRegister(3DNS_SD),
DNSServiceResolve(3DNS_SD), attributes(5)
SunOS 5.11 Last change: 20 Aug 2007 2
DNS Service Discovery Library FunctionsDNSServiceQueryRecord(3DNS_SD)
SunOS 5.11 Last change: 20 Aug 2007 3