EpcDispatcher

EpcDispatcher — publish DNS-SD services

Stability Level

Private, unless otherwise indicated

Synopsis


#include <libepc/dispatcher.h>


enum                EpcAddressFamily;
                    EpcDispatcherPrivate;
                    EpcDispatcherClass;
                    EpcDispatcher;
EpcDispatcher*      epc_dispatcher_new                  (const gchar *name);
void                epc_dispatcher_reset                (EpcDispatcher *dispatcher);
void                epc_dispatcher_add_service          (EpcDispatcher *dispatcher,
                                                         EpcAddressFamily protocol,
                                                         const gchar *type,
                                                         const gchar *domain,
                                                         const gchar *host,
                                                         guint16 port,
                                                         ...);
void                epc_dispatcher_add_service_subtype  (EpcDispatcher *dispatcher,
                                                         const gchar *type,
                                                         const gchar *subtype);
void                epc_dispatcher_set_service_details  (EpcDispatcher *dispatcher,
                                                         const gchar *type,
                                                         ...);
void                epc_dispatcher_set_name             (EpcDispatcher *dispatcher,
                                                         const gchar *name);
const gchar*        epc_dispatcher_get_name             (EpcDispatcher *dispatcher);
const gchar*        epc_dispatcher_get_host_name        (EpcDispatcher *dispatcher);

Object Hierarchy


  GObject
   +----EpcDispatcher

Properties


  "name"                     gchar*                : Read / Write / Construct

Description

The EpcDispatcher object provides an easy method for publishing DNS-SD services. Unlike established APIs like Avahi or HOWL the EpcDispatcher doesn't expose any state changes reported by the DNS-SD daemon, but instead tries to handle them automatically. Such state changes include, for instance, name collisions or a restart of the DNS-SD daemon.

Example 8. Publish a printing service

  dispatcher = epc_dispatcher_new ("Dead Tree Desecrator");

  epc_dispatcher_add_service (dispatcher, EPC_ADDRESS_IPV4, "_ipp._tcp",
                              NULL, NULL, 651, "path=/printers", NULL);
  epc_dispatcher_add_service (dispatcher, EPC_ADDRESS_UNSPEC,
                              "_duplex._sub._printer._tcp",
                              NULL, NULL, 515, NULL);
 


Details

enum EpcAddressFamily

typedef enum 
{
  EPC_ADDRESS_UNSPEC = AF_UNSPEC,
  EPC_ADDRESS_IPV4 = AF_INET,
  EPC_ADDRESS_IPV6 = AF_INET6
}
EpcAddressFamily;

The address family to use for contacting network services.

EPC_ADDRESS_UNSPEC No preferences exist. Use all address families supported.
EPC_ADDRESS_IPV4 Exclusively use IPv4 for addressing network services.
EPC_ADDRESS_IPV6 Exclusively use IPv6 for addressing network services.

EpcDispatcherPrivate

typedef struct _EpcDispatcherPrivate EpcDispatcherPrivate;

Private fields of the EpcDispatcher class.


EpcDispatcherClass

typedef struct {
} EpcDispatcherClass;

Virtual methods of the EpcDispatcher class.


EpcDispatcher

typedef struct _EpcDispatcher EpcDispatcher;

Public fields of the EpcDispatcher class.


epc_dispatcher_new ()

EpcDispatcher*      epc_dispatcher_new                  (const gchar *name);

Creates a new EpcDispatcher object for announcing a DNS-SD service. The service is announced on all network interfaces.

Call epc_dispatcher_add_service to actually announce a service.

name : the human friendly name of the service
Returns : the newly created EpcDispatcher object.

epc_dispatcher_reset ()

void                epc_dispatcher_reset                (EpcDispatcher *dispatcher);

Revokes all service announcements of this EpcDispatcher.

dispatcher : a EpcDispatcher

epc_dispatcher_add_service ()

void                epc_dispatcher_add_service          (EpcDispatcher *dispatcher,
                                                         EpcAddressFamily protocol,
                                                         const gchar *type,
                                                         const gchar *domain,
                                                         const gchar *host,
                                                         guint16 port,
                                                         ...);

Announces a TCP/IP service via DNS-SD.

The service type shall be a well-known DNS-SD service type as listed on http://www.dns-sd.org/ServiceTypes.html. This function tries to announce both the base service type and the sub service type when the service name contains more than just one dot: Passing "_anon._sub._ftp._tcp" for type will announce the services "_ftp._tcp" and "_anon._sub._ftp._tcp".

The function can be called more than once. Is this necessary when the server provides different access methods. For instance a web server could provide HTTP and encrypted HTTPS services at the same time. Calling this function multiple times also is useful for servers providing the same service at different, but not all network interfaces of the host.

When passing NULL for domain, the service is announced within the local network only, otherwise it is announced at the specified DNS domain. The responsible server must be configured to support DNS-SD.

Pass NULL for host to use the official host name of the machine to announce the service. On machines with multiple DNS entries you might want to explictly choose a fully qualified DNS name to announce the service.

dispatcher : a EpcDispatcher
protocol : the EpcAddressFamily this service supports
type : the machine friendly name of the service
domain : the DNS domain for the announcement, or NULL
host : the fully qualified host name of the service, or NULL
port : the TCP/IP port of the service
... : an optional list of TXT records, terminated by NULL

epc_dispatcher_add_service_subtype ()

void                epc_dispatcher_add_service_subtype  (EpcDispatcher *dispatcher,
                                                         const gchar *type,
                                                         const gchar *subtype);

Announces an additional sub service for a registered DNS-SD service.

Note

This function will fail silently, when the service specified by type hasn't been registered yet.

dispatcher : a EpcDispatcher
type : the base service type
subtype : the sub service type

epc_dispatcher_set_service_details ()

void                epc_dispatcher_set_service_details  (EpcDispatcher *dispatcher,
                                                         const gchar *type,
                                                         ...);

Updates the list of TXT records for a registered DNS-SD service. The TXT records are specified by the service type and usually have the form of key-value pairs:

 path=/dwarf-blog/

Note

This function will fail silently, when the service specified by type hasn't been registered yet.

dispatcher : a EpcDispatcher
type : the service type
... : a list of TXT records, terminated by NULL

epc_dispatcher_set_name ()

void                epc_dispatcher_set_name             (EpcDispatcher *dispatcher,
                                                         const gchar *name);

Changes the user friendly name used for announcing services. See "name".

dispatcher : a EpcDispatcher
name : the new user friendly name

epc_dispatcher_get_name ()

const gchar*        epc_dispatcher_get_name             (EpcDispatcher *dispatcher);

Queries the user friendly name used for announcing services. See "name".

dispatcher : a EpcDispatcher
Returns : The user friendly name of the service.

epc_dispatcher_get_host_name ()

const gchar*        epc_dispatcher_get_host_name        (EpcDispatcher *dispatcher);

Query the official host name of this machine.

dispatcher : a EpcDispatcher
Returns : The official host name, or NULL on error.

Property Details

The "name" property

  "name"                     gchar*                : Read / Write / Construct

User friendly name of the service.

Default value: NULL