DNS Service Discovery Library Functions
DNSServiceRegister(3DNS_SD)
NAME
DNSServiceRegister - register service with DNS
SYNOPSIS
cc [ flag ... ] file ... -ldns_sd [ library ... ]
#include
DNSServiceErrorType DNSServiceRegister(DNSServiceRef *sdRef,
DNSServiceFlags flags, uint32_t interfaceIndex,
const char *name, const char *regtype, const char *domain, const char *host,uint16_t port, uint16_t *txtLen, const void *txtRecord
DNSServiceServiceRegisterReply callBack void *context);typedef void(*DNSServiceRegisterReply)(DNSServiceRef sdRef,
DNSServiceFlags flags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, void *context);DESCRIPTION
The DNSServiceRegister function is used by clients to adver-
tise a service that uses DNS. The service is registered with multicast DNS if the domain name is .local or the interface requested is local only. Otherwise, the service registrationis attempted with the unicast DNS server. The callback argu-
ment should point to a function of type DNSServiceRe-
gisterReply listed above. The sdRef parameter points to an uninitialized DNSServiceRefinstance. If the DNSServiceRegister() call succeeds, sdRef
is initialized and kDNSServiceErr_NoError is returned. The
service registration remains active until the client ter-
minates the registration by passing the initialized sdRef toDNSServiceRefDeallocate(). The interfaceIndex when non-zero
specifies the interface on which the service should be registered. Most applications pass 0 to register the service on all interfaces. See the section "Constants for specifyingan interface index" in
for more details. The flags parameter determines the renaming behavior on a ser-
vice name conflict. Most applications pass 0 to allow auto-
rename of the service name in case of a name conflict. Applications can pass the flag kDNSServiceFlagsNoAutoRenamedefined in
to disable auto-rename. The regtype indicates the service type followed by the pro-
tocol, separated by a dot, for example "_ftp._tcp.". The
SunOS 5.11 Last change: 20 Aug 2007 1
DNS Service Discovery Library FunctionsDNSServiceRegister(3DNS_SD)
service type must be an underscore that is followed by 1 to 14 characters that can be letters, digits, or hyphens. Thetransport protocol must be _tcp or _udp. New service types
should be registered at http://www.dns-
sd.org/ServiceTypes.html. The domain parameter specifies the domain on which a service is advertised. Most applications leave the domain parameter NULL to register the service in default domains. The host parameter specifies the SRV target
host name. Most applications do not specify the host parame-
ter value. Instead, the default host name of the machine isused. The port value on which the service accepts connec-
tions must be passed in network byte order. A value of 0 fora port is passed to register placeholder services. Place-
holder services are not found when browsing, but otherclients cannot register with the same name as the place-
holder service. The txtLen parameter specifies the length of the passed txtRecord in bytes. The value must be zero if the txtRecord passed is NULL. The txtRecord points to the TXT recordrdata. A non-NULL txtRecord must be a properly formatted
DNSTXT record. For more details see the DNSServiceRegister
call defined in
a function to be called when registration completes or when the call asynchronously fails. The client can pass NULL for the callback and not be notified of the registration results. The callback argument points to or asynchronous errors. The client may not pass the NoAu-
toRename flag if the callback is NULL. The client can unre-
gister the service at any time via DNSServiceRefDeallo-
cate(). The callback function argument sdRef is initialized byDNSServiceRegister(). The flags argument in the callback
function is currently unused and reserved for future use. The error code returned to the callback iskDNSServiceErr_NoError on success. Otherwise, an error code
defined in
is returned to indicate an error con- dition such as a name conflict in kDNSServiceFlagsNoAu-
toRename mode. The name argument holds the registered ser-
vice name and the regtype argument is the registered servicetype passed to DNSServiceRegister(). The domain argument
returned in the callback indicates the domain on which the service was registered.RETURN VALUES
The DNSServiceRegister function returns
kDNSServiceErr_NoError on success. Otherwise, an error code
defined in
subsequent asynchronous errors are delivered to theis returned. Upon registration, any SunOS 5.11 Last change: 20 Aug 2007 2
DNS Service Discovery Library FunctionsDNSServiceRegister(3DNS_SD)
callback.ATTRIBUTES
See attributes(5) for description of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Interface Stability | Committed ||_____________________________|_____________________________|
| MT-Level | Safe |
|_____________________________|_____________________________|
SEE ALSO
DNSServiceRefDeallocate(3DNS_SD), attributes(5)
SunOS 5.11 Last change: 20 Aug 2007 3
DNS Service Discovery Library FunctionsDNSServiceRegister(3DNS_SD)
SunOS 5.11 Last change: 20 Aug 2007 4