avahi  0.7
publish.h File Reference

Publishing 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.

Typedefs

typedef struct AvahiEntryGroup AvahiEntryGroup
 An entry group object. More...
 
typedef void(* AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata)
 The function prototype for the callback of an AvahiEntryGroup. More...
 

Functions

Construction and destruction
AvahiEntryGroupavahi_entry_group_new (AvahiClient *c, AvahiEntryGroupCallback callback, void *userdata)
 Create a new AvahiEntryGroup object. More...
 
int avahi_entry_group_free (AvahiEntryGroup *)
 Clean up and free an AvahiEntryGroup object. More...
 
State
int avahi_entry_group_commit (AvahiEntryGroup *)
 Commit an AvahiEntryGroup. More...
 
int avahi_entry_group_reset (AvahiEntryGroup *)
 Reset an AvahiEntryGroup. More...
 
int avahi_entry_group_get_state (AvahiEntryGroup *)
 Get an AvahiEntryGroup's state. More...
 
int avahi_entry_group_is_empty (AvahiEntryGroup *)
 Check if an AvahiEntryGroup is empty. More...
 
AvahiClientavahi_entry_group_get_client (AvahiEntryGroup *)
 Get an AvahiEntryGroup's owning client instance. More...
 
Adding and updating entries
int avahi_entry_group_add_service (AvahiEntryGroup *group, AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, const char *name, const char *type, const char *domain, const char *host, uint16_t port,...) AVAHI_GCC_SENTINEL
 Add a service. More...
 
int avahi_entry_group_add_service_strlst (AvahiEntryGroup *group, AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, const char *name, const char *type, const char *domain, const char *host, uint16_t port, AvahiStringList *txt)
 Add a service, takes an AvahiStringList for TXT records. More...
 
int avahi_entry_group_add_service_subtype (AvahiEntryGroup *group, AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, const char *name, const char *type, const char *domain, const char *subtype)
 Add a subtype for a service. More...
 
int avahi_entry_group_update_service_txt (AvahiEntryGroup *g, AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, const char *name, const char *type, const char *domain,...) AVAHI_GCC_SENTINEL
 Update a TXT record for an existing service. More...
 
int avahi_entry_group_update_service_txt_strlst (AvahiEntryGroup *g, AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, const char *name, const char *type, const char *domain, AvahiStringList *strlst)
 Update a TXT record for an existing service. More...
 
int avahi_entry_group_add_record (AvahiEntryGroup *group, AvahiIfIndex interface, AvahiProtocol protocol, AvahiPublishFlags flags, const char *name, uint16_t clazz, uint16_t type, uint32_t ttl, const void *rdata, size_t size)
 Add an arbitrary record. More...
 

Detailed Description

Publishing Client API.

Definition in file publish.h.

Typedef Documentation

◆ AvahiEntryGroup

An entry group object.

Definition at line 43 of file publish.h.

◆ AvahiEntryGroupCallback

typedef void(* AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata)

The function prototype for the callback of an AvahiEntryGroup.

Definition at line 46 of file publish.h.

Function Documentation

◆ avahi_entry_group_add_record()

int avahi_entry_group_add_record ( AvahiEntryGroup group,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
uint16_t  clazz,
uint16_t  type,
uint32_t  ttl,
const void *  rdata,
size_t  size 
)

Add an arbitrary record.

I hope you know what you do.

◆ avahi_entry_group_add_service()

int avahi_entry_group_add_service ( AvahiEntryGroup group,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
const char *  type,
const char *  domain,
const char *  host,
uint16_t  port,
  ... 
)

Add a service.

Takes a variable NULL terminated list of TXT record strings as last arguments. Please note that this service is not announced on the network before avahi_entry_group_commit() is called.

Parameters
interfaceThe interface this service shall be announced on. We recommend to pass AVAHI_IF_UNSPEC here, to announce on all interfaces.
protocolThe protocol this service shall be announced with, i.e. MDNS over IPV4 or MDNS over IPV6. We recommend to pass AVAHI_PROTO_UNSPEC here, to announce this service on all protocols the daemon supports.
flagsUsually 0, unless you know what you do
nameThe name for the new service. Must be valid service name. i.e. a string shorter than 63 characters and valid UTF-8. May not be NULL.
typeThe service type for the new service, such as _http._tcp. May not be NULL.
domainThe domain to register this domain in. We recommend to pass NULL here, to let the daemon decide
hostThe host this services is residing on. We recommend to pass NULL here, the daemon will than automatically insert the local host name in that case
portThe IP port number of this service
Examples:
client-publish-service.c.

◆ avahi_entry_group_add_service_strlst()

int avahi_entry_group_add_service_strlst ( AvahiEntryGroup group,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
const char *  type,
const char *  domain,
const char *  host,
uint16_t  port,
AvahiStringList txt 
)

Add a service, takes an AvahiStringList for TXT records.

Arguments have the same meaning as for avahi_entry_group_add_service().

Parameters
txtThe TXT data for this service. You may free this object after calling this function, it is not referenced any further

◆ avahi_entry_group_add_service_subtype()

int avahi_entry_group_add_service_subtype ( AvahiEntryGroup group,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
const char *  type,
const char *  domain,
const char *  subtype 
)

Add a subtype for a service.

The service should already be existent in the entry group. You may add as many subtypes for a service as you wish.

Parameters
interfaceThe interface this subtype shall be announced on. This should match the value passed for the original avahi_entry_group_add_service() call.
protocolThe protocol this subtype shall be announced with. This should match the value passed for the original avahi_entry_group_add_service() call.
flagsOnly != 0 if you really know what you do
nameThe name of the service, as passed to avahi_entry_group_add_service(). May not be NULL.
typeThe type of the service, as passed to avahi_entry_group_add_service(). May not be NULL.
domainThe domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL.
subtypeThe new subtype to register for the specified service. May not be NULL.
Examples:
client-publish-service.c.

◆ avahi_entry_group_commit()

int avahi_entry_group_commit ( AvahiEntryGroup )

Commit an AvahiEntryGroup.

The entries in the entry group are now registered on the network. Commiting empty entry groups is considered an error.

Examples:
client-publish-service.c.

◆ avahi_entry_group_free()

int avahi_entry_group_free ( AvahiEntryGroup )

Clean up and free an AvahiEntryGroup object.

◆ avahi_entry_group_get_client()

AvahiClient* avahi_entry_group_get_client ( AvahiEntryGroup )

Get an AvahiEntryGroup's owning client instance.

Examples:
client-publish-service.c.

◆ avahi_entry_group_get_state()

int avahi_entry_group_get_state ( AvahiEntryGroup )

Get an AvahiEntryGroup's state.

◆ avahi_entry_group_is_empty()

int avahi_entry_group_is_empty ( AvahiEntryGroup )

Check if an AvahiEntryGroup is empty.

Examples:
client-publish-service.c.

◆ avahi_entry_group_new()

AvahiEntryGroup* avahi_entry_group_new ( AvahiClient c,
AvahiEntryGroupCallback  callback,
void *  userdata 
)

Create a new AvahiEntryGroup object.

Parameters
callbackThis callback is called whenever the state of this entry group changes. May not be NULL. Please note that this function is called for the first time from within the avahi_entry_group_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_entry_group_new(). A common mistake is to store the AvahiEntryGroup pointer returned by avahi_entry_group_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiEntryGroup pointer passed to the callback function instead of the global pointer.
userdataThis arbitrary user data pointer will be passed to the callback functon
Examples:
client-publish-service.c.

◆ avahi_entry_group_reset()

int avahi_entry_group_reset ( AvahiEntryGroup )

Reset an AvahiEntryGroup.

This takes effect immediately.

Examples:
client-publish-service.c.

◆ avahi_entry_group_update_service_txt()

int avahi_entry_group_update_service_txt ( AvahiEntryGroup g,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
const char *  type,
const char *  domain,
  ... 
)

Update a TXT record for an existing service.

The service should already be existent in the entry group.

Parameters
interfaceThe interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call.
protocolThe protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call.
flagsOnly != 0 if you really know what you do
nameThe name of the service, as passed to avahi_entry_group_add_service(). May not be NULL.
typeThe type of the service, as passed to avahi_entry_group_add_service(). May not be NULL.
domainThe domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL.

◆ avahi_entry_group_update_service_txt_strlst()

int avahi_entry_group_update_service_txt_strlst ( AvahiEntryGroup g,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
const char *  type,
const char *  domain,
AvahiStringList strlst 
)

Update a TXT record for an existing service.

Similar to avahi_entry_group_update_service_txt() but takes an AvahiStringList for the TXT strings, instead of a NULL terminated list of arguments.