avahi  0.7
lookup.h File Reference

Lookup Client API. More...

#include <inttypes.h>
#include <avahi-common/cdecl.h>
#include <avahi-common/address.h>
#include <avahi-common/strlst.h>
#include <avahi-common/defs.h>
#include <avahi-common/watch.h>
#include <avahi-common/gccmacro.h>
#include <avahi-client/client.h>

Go to the source code of this file.

Domain Browser

typedef struct AvahiDomainBrowser AvahiDomainBrowser
 A domain browser object. More...
 
typedef void(* AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void *userdata)
 The function prototype for the callback of an AvahiDomainBrowser. More...
 
AvahiDomainBrowseravahi_domain_browser_new (AvahiClient *client, AvahiIfIndex interface, AvahiProtocol protocol, const char *domain, AvahiDomainBrowserType btype, AvahiLookupFlags flags, AvahiDomainBrowserCallback callback, void *userdata)
 Browse for domains on the local network. More...
 
AvahiClientavahi_domain_browser_get_client (AvahiDomainBrowser *)
 Get the parent client of an AvahiDomainBrowser object. More...
 
int avahi_domain_browser_free (AvahiDomainBrowser *)
 Cleans up and frees an AvahiDomainBrowser object. More...
 

Service Browser

typedef struct AvahiServiceBrowser AvahiServiceBrowser
 A service browser object. More...
 
typedef void(* AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata)
 The function prototype for the callback of an AvahiServiceBrowser. More...
 
AvahiServiceBrowseravahi_service_browser_new (AvahiClient *client, AvahiIfIndex interface, AvahiProtocol protocol, const char *type, const char *domain, AvahiLookupFlags flags, AvahiServiceBrowserCallback callback, void *userdata)
 Browse for services of a type on the network. More...
 
AvahiClientavahi_service_browser_get_client (AvahiServiceBrowser *)
 Get the parent client of an AvahiServiceBrowser object. More...
 
int avahi_service_browser_free (AvahiServiceBrowser *)
 Cleans up and frees an AvahiServiceBrowser object. More...
 

Service Resolver

typedef struct AvahiServiceResolver AvahiServiceResolver
 A service resolver object. More...
 
typedef void(* AvahiServiceResolverCallback) (AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *a, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, void *userdata)
 The function prototype for the callback of an AvahiServiceResolver. More...
 
AvahiServiceResolveravahi_service_resolver_new (AvahiClient *client, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, AvahiProtocol aprotocol, AvahiLookupFlags flags, AvahiServiceResolverCallback callback, void *userdata)
 Create a new service resolver object. More...
 
AvahiClientavahi_service_resolver_get_client (AvahiServiceResolver *)
 Get the parent client of an AvahiServiceResolver object. More...
 
int avahi_service_resolver_free (AvahiServiceResolver *r)
 Free a service resolver object. More...
 

Record Browser

typedef struct AvahiRecordBrowser AvahiRecordBrowser
 A record browser object. More...
 
typedef void(* AvahiRecordBrowserCallback) (AvahiRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, uint16_t clazz, uint16_t type, const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata)
 The function prototype for the callback of an AvahiRecordBrowser. More...
 
AvahiRecordBrowseravahi_record_browser_new (AvahiClient *client, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, uint16_t clazz, uint16_t type, AvahiLookupFlags flags, AvahiRecordBrowserCallback callback, void *userdata)
 Browse for records of a type on the local network. More...
 
AvahiClientavahi_record_browser_get_client (AvahiRecordBrowser *)
 Get the parent client of an AvahiRecordBrowser object. More...
 
int avahi_record_browser_free (AvahiRecordBrowser *)
 Cleans up and frees an AvahiRecordBrowser object. More...
 

Detailed Description

Lookup Client API.

Definition in file lookup.h.

Typedef Documentation

◆ AvahiDomainBrowser

A domain browser object.

Definition at line 44 of file lookup.h.

◆ AvahiDomainBrowserCallback

typedef void(* AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void *userdata)

The function prototype for the callback of an AvahiDomainBrowser.

Definition at line 47 of file lookup.h.

◆ AvahiRecordBrowser

A record browser object.

Definition at line 276 of file lookup.h.

◆ AvahiRecordBrowserCallback

typedef void(* AvahiRecordBrowserCallback) (AvahiRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, uint16_t clazz, uint16_t type, const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata)

The function prototype for the callback of an AvahiRecordBrowser.

Definition at line 279 of file lookup.h.

◆ AvahiServiceBrowser

A service browser object.

Definition at line 78 of file lookup.h.

◆ AvahiServiceBrowserCallback

typedef void(* AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata)

The function prototype for the callback of an AvahiServiceBrowser.

Definition at line 81 of file lookup.h.

◆ AvahiServiceResolver

A service resolver object.

Definition at line 157 of file lookup.h.

◆ AvahiServiceResolverCallback

typedef void(* AvahiServiceResolverCallback) (AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *a, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, void *userdata)

The function prototype for the callback of an AvahiServiceResolver.

Definition at line 160 of file lookup.h.

Function Documentation

◆ avahi_domain_browser_free()

int avahi_domain_browser_free ( AvahiDomainBrowser )

Cleans up and frees an AvahiDomainBrowser object.

◆ avahi_domain_browser_get_client()

AvahiClient* avahi_domain_browser_get_client ( AvahiDomainBrowser )

Get the parent client of an AvahiDomainBrowser object.

◆ avahi_domain_browser_new()

AvahiDomainBrowser* avahi_domain_browser_new ( AvahiClient client,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
const char *  domain,
AvahiDomainBrowserType  btype,
AvahiLookupFlags  flags,
AvahiDomainBrowserCallback  callback,
void *  userdata 
)

Browse for domains on the local network.

◆ avahi_record_browser_free()

int avahi_record_browser_free ( AvahiRecordBrowser )

Cleans up and frees an AvahiRecordBrowser object.

◆ avahi_record_browser_get_client()

AvahiClient* avahi_record_browser_get_client ( AvahiRecordBrowser )

Get the parent client of an AvahiRecordBrowser object.

◆ avahi_record_browser_new()

AvahiRecordBrowser* avahi_record_browser_new ( AvahiClient client,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
const char *  name,
uint16_t  clazz,
uint16_t  type,
AvahiLookupFlags  flags,
AvahiRecordBrowserCallback  callback,
void *  userdata 
)

Browse for records of a type on the local network.

◆ avahi_service_browser_free()

int avahi_service_browser_free ( AvahiServiceBrowser )

Cleans up and frees an AvahiServiceBrowser object.

Examples:
client-browse-services.c.

◆ avahi_service_browser_get_client()

AvahiClient* avahi_service_browser_get_client ( AvahiServiceBrowser )

Get the parent client of an AvahiServiceBrowser object.

Examples:
client-browse-services.c.

◆ avahi_service_browser_new()

AvahiServiceBrowser* avahi_service_browser_new ( AvahiClient client,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
const char *  type,
const char *  domain,
AvahiLookupFlags  flags,
AvahiServiceBrowserCallback  callback,
void *  userdata 
)

Browse for services of a type on the network.

In most cases you probably want to pass AVAHI_IF_UNSPEC and AVAHI_PROTO_UNSPED in interface, resp. protocol to browse on all local networks. The specified callback will be called whenever a new service appears or is removed from the network. Please note that events may be collapsed to minimize traffic (i.e. a REMOVED followed by a NEW for the same service data is dropped because redundant). If you want to subscribe to service data changes, you should use avahi_service_resolver_new() and keep it open, in which case you will be notified via AVAHI_RESOLVE_FOUND everytime the service data changes.

Parameters
interfaceIn most cases pass AVAHI_IF_UNSPEC here
protocolIn most cases pass AVAHI_PROTO_UNSPEC here
typeA service type such as "_http._tcp"
domainA domain to browse in. In most cases you want to pass NULL here for the default domain (usually ".local")
Examples:
client-browse-services.c.

◆ avahi_service_resolver_free()

int avahi_service_resolver_free ( AvahiServiceResolver r)

Free a service resolver object.

Examples:
client-browse-services.c.

◆ avahi_service_resolver_get_client()

AvahiClient* avahi_service_resolver_get_client ( AvahiServiceResolver )

Get the parent client of an AvahiServiceResolver object.

Examples:
client-browse-services.c.

◆ avahi_service_resolver_new()

AvahiServiceResolver* avahi_service_resolver_new ( AvahiClient client,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
const char *  name,
const char *  type,
const char *  domain,
AvahiProtocol  aprotocol,
AvahiLookupFlags  flags,
AvahiServiceResolverCallback  callback,
void *  userdata 
)

Create a new service resolver object.

Please make sure to pass all the service data you received via avahi_service_browser_new()'s callback function, especially interface and protocol. The protocol argument specifies the protocol (IPv4 or IPv6) to use as transport for the queries which are sent out by this resolver. The aprotocol argument specifies the adress family (IPv4 or IPv6) of the address of the service we are looking for. Generally, on "protocol" you should only pass what was supplied to you as parameter to your AvahiServiceBrowserCallback. In "aprotocol" you should pass what your application code can deal with when connecting to the service. Or, more technically speaking: protocol specifies if the mDNS queries should be sent as UDP/IPv4 resp. UDP/IPv6 packets. aprotocol specifies whether the query is for a A resp. AAAA resource record.

Parameters
interfacePass the interface argument you received in AvahiServiceBrowserCallback here.
protocolPass the protocol argument you received in AvahiServiceBrowserCallback here.
namePass the name argument you received in AvahiServiceBrowserCallback here.
typePass the type argument you received in AvahiServiceBrowserCallback here.
domainPass the domain argument you received in AvahiServiceBrowserCallback here.
aprotocolThe desired address family of the service address to resolve. AVAHI_PROTO_UNSPEC if your application can deal with both IPv4 and IPv6
Examples:
client-browse-services.c.