diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-04-14 12:56:48 +0100 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-04-14 12:56:48 +0100 |
commit | 0b624384cd52be20e61284551d832b499d7b7707 (patch) | |
tree | 6f95a4bbef47abc9720b96c0722e8f632aef228a /linux/avahi-client | |
download | libphidget21-0b624384cd52be20e61284551d832b499d7b7707.tar.gz |
Imported Upstream version 2.1.8.20120216upstream/2.1.8.20120216
Diffstat (limited to '')
-rw-r--r-- | linux/avahi-client/client.h | 119 | ||||
-rw-r--r-- | linux/avahi-client/lookup.h | 295 | ||||
-rw-r--r-- | linux/avahi-client/publish.h | 174 |
3 files changed, 588 insertions, 0 deletions
diff --git a/linux/avahi-client/client.h b/linux/avahi-client/client.h new file mode 100644 index 0000000..52fccb8 --- /dev/null +++ b/linux/avahi-client/client.h @@ -0,0 +1,119 @@ +#ifndef fooclienthfoo +#define fooclienthfoo + +/* $Id: client.h 1477 2007-05-09 19:45:54Z lennart $ */ + +/*** + This file is part of avahi. + + avahi is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + avahi is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with avahi; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#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> + +/** \file client.h Definitions and functions for the client API over D-Bus */ + +AVAHI_C_DECL_BEGIN + +/** A connection context */ +typedef struct AvahiClient AvahiClient; + +/** States of a client object, a superset of AvahiServerState */ +typedef enum { + AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING, /**< Server state: REGISTERING */ + AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING, /**< Server state: RUNNING */ + AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION, /**< Server state: COLLISION */ + AVAHI_CLIENT_FAILURE = 100, /**< Some kind of error happened on the client side */ + AVAHI_CLIENT_CONNECTING = 101 /**< We're still connecting. This state is only entered when AVAHI_CLIENT_NO_FAIL has been passed to avahi_client_new() and the daemon is not yet available. */ +} AvahiClientState; + +typedef enum { + AVAHI_CLIENT_IGNORE_USER_CONFIG = 1, /**< Don't read user configuration */ + AVAHI_CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter AVAHI_CLIENT_CONNECTING state and wait for the daemon to appear */ +} AvahiClientFlags; + +/** The function prototype for the callback of an AvahiClient */ +typedef void (*AvahiClientCallback) ( + AvahiClient *s, + AvahiClientState state /**< The new state of the client */, + void* userdata /**< The user data that was passed to avahi_client_new() */); + +/** @{ \name Construction and destruction */ + +/** Creates a new client instance */ +AvahiClient* avahi_client_new ( + const AvahiPoll *poll_api /**< The abstract event loop API to use */, + AvahiClientFlags flags /**< Some flags to modify the behaviour of the client library */, + AvahiClientCallback callback /**< A callback that is called whenever the state of the client changes. This may be NULL. Please note that this function is called for the first time from within the avahi_client_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_client_new(). A common mistake is to store the AvahiClient pointer returned by avahi_client_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 AvahiClient pointer passed to the callback function instead of the global pointer. */, + void *userdata /**< Some arbitrary user data pointer that will be passed to the callback function */, + int *error /**< If creation of the client fails, this integer will contain the error cause. May be NULL if you aren't interested in the reason why avahi_client_new() failed. */); + +/** Free a client instance. This will automatically free all + * associated browser, resolve and entry group objects. All pointers + * to such objects become invalid! */ +void avahi_client_free(AvahiClient *client); + +/** @} */ + +/** @{ \name Properties */ + +/** Get the version of the server */ +const char* avahi_client_get_version_string (AvahiClient*); + +/** Get host name */ +const char* avahi_client_get_host_name (AvahiClient*); + +/** Set host name. \since 0.6.13 */ +int avahi_client_set_host_name(AvahiClient*, const char *name); + +/** Get domain name */ +const char* avahi_client_get_domain_name (AvahiClient*); + +/** Get FQDN domain name */ +const char* avahi_client_get_host_name_fqdn (AvahiClient*); + +/** Get state */ +AvahiClientState avahi_client_get_state(AvahiClient *client); + +/** @{ \name Error Handling */ + +/** Get the last error number. See avahi_strerror() for converting this error code into a human readable string. */ +int avahi_client_errno (AvahiClient*); + +/** @} */ + +/** \cond fulldocs */ +/** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */ +uint32_t avahi_client_get_local_service_cookie(AvahiClient *client); +/** \endcond */ + +/** @{ \name Libc NSS Support */ + +/** Return 1 if gethostbyname() supports mDNS lookups, 0 otherwise. \since 0.6.5 */ +int avahi_nss_support(void); + +/** @} */ + +AVAHI_C_DECL_END + +#endif diff --git a/linux/avahi-client/lookup.h b/linux/avahi-client/lookup.h new file mode 100644 index 0000000..c417fcf --- /dev/null +++ b/linux/avahi-client/lookup.h @@ -0,0 +1,295 @@ +#ifndef fooclientlookuphfoo +#define fooclientlookuphfoo + +/* $Id: lookup.h 1477 2007-05-09 19:45:54Z lennart $ */ + +/*** + This file is part of avahi. + + avahi is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + avahi is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with avahi; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#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> + +/** \file avahi-client/lookup.h Lookup Client API */ + +/** \example client-browse-services.c Example how to browse for DNS-SD + * services using the client interface to avahi-daemon. */ + +AVAHI_C_DECL_BEGIN + +/** @{ \name Domain Browser */ + +/** A domain browser object */ +typedef struct AvahiDomainBrowser AvahiDomainBrowser; + +/** The function prototype for the callback of an AvahiDomainBrowser */ +typedef void (*AvahiDomainBrowserCallback) ( + AvahiDomainBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *domain, + AvahiLookupResultFlags flags, + void *userdata); + +/** Browse for domains on the local network */ +AvahiDomainBrowser* avahi_domain_browser_new ( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *domain, + AvahiDomainBrowserType btype, + AvahiLookupFlags flags, + AvahiDomainBrowserCallback callback, + void *userdata); + +/** Get the parent client of an AvahiDomainBrowser object */ +AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *); + +/** Cleans up and frees an AvahiDomainBrowser object */ +int avahi_domain_browser_free (AvahiDomainBrowser *); + +/** @} */ + +/** @{ \name Service Browser */ + +/** A service browser object */ +typedef struct AvahiServiceBrowser AvahiServiceBrowser; + +/** The function prototype for the callback of an AvahiServiceBrowser */ +typedef void (*AvahiServiceBrowserCallback) ( + AvahiServiceBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *name, + const char *type, + const char *domain, + AvahiLookupResultFlags flags, + void *userdata); + +/** Browse for services of a type on the local network */ +AvahiServiceBrowser* avahi_service_browser_new ( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *type, + const char *domain, + AvahiLookupFlags flags, + AvahiServiceBrowserCallback callback, + void *userdata); + +/** Get the parent client of an AvahiServiceBrowser object */ +AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *); + +/** Cleans up and frees an AvahiServiceBrowser object */ +int avahi_service_browser_free (AvahiServiceBrowser *); + +/** @} */ + +/** \cond fulldocs */ +/** A service type browser object */ +typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser; + +/** The function prototype for the callback of an AvahiServiceTypeBrowser */ +typedef void (*AvahiServiceTypeBrowserCallback) ( + AvahiServiceTypeBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *type, + const char *domain, + AvahiLookupResultFlags flags, + void *userdata); + +/** Browse for service types on the local network */ +AvahiServiceTypeBrowser* avahi_service_type_browser_new ( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *domain, + AvahiLookupFlags flags, + AvahiServiceTypeBrowserCallback callback, + void *userdata); + +/** Get the parent client of an AvahiServiceTypeBrowser object */ +AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *); + +/** Cleans up and frees an AvahiServiceTypeBrowser object */ +int avahi_service_type_browser_free (AvahiServiceTypeBrowser *); + +/** \endcond */ + +/** @{ \name Service Resolver */ + +/** A service resolver object */ +typedef struct AvahiServiceResolver AvahiServiceResolver; + +/** The function prototype for the callback of an AvahiServiceResolver */ +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); + +/** 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. */ +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); + +/** Get the parent client of an AvahiServiceResolver object */ +AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *); + +/** Free a service resolver object */ +int avahi_service_resolver_free(AvahiServiceResolver *r); + +/** @} */ + +/** \cond fulldocs */ +/** A service resolver object */ +typedef struct AvahiHostNameResolver AvahiHostNameResolver; + +/** The function prototype for the callback of an AvahiHostNameResolver */ +typedef void (*AvahiHostNameResolverCallback) ( + AvahiHostNameResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const char *name, + const AvahiAddress *a, + AvahiLookupResultFlags flags, + void *userdata); + +/** Create a new hostname resolver object */ +AvahiHostNameResolver * avahi_host_name_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const char *name, + AvahiProtocol aprotocol, + AvahiLookupFlags flags, + AvahiHostNameResolverCallback callback, + void *userdata); + +/** Get the parent client of an AvahiHostNameResolver object */ +AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *); + +/** Free a hostname resolver object */ +int avahi_host_name_resolver_free(AvahiHostNameResolver *r); + +/** An address resolver object */ +typedef struct AvahiAddressResolver AvahiAddressResolver; + +/** The function prototype for the callback of an AvahiAddressResolver */ +typedef void (*AvahiAddressResolverCallback) ( + AvahiAddressResolver *r, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, + const AvahiAddress *a, + const char *name, + AvahiLookupResultFlags flags, + void *userdata); + +/** Create a new address resolver object from an AvahiAddress object */ +AvahiAddressResolver* avahi_address_resolver_new( + AvahiClient *client, + AvahiIfIndex interface, + AvahiProtocol protocol, + const AvahiAddress *a, + AvahiLookupFlags flags, + AvahiAddressResolverCallback callback, + void *userdata); + +/** Get the parent client of an AvahiAddressResolver object */ +AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *); + +/** Free a AvahiAddressResolver resolver object */ +int avahi_address_resolver_free(AvahiAddressResolver *r); + +/** \endcond */ + +/** @{ \name Record Browser */ + +/** A record browser object */ +typedef struct AvahiRecordBrowser AvahiRecordBrowser; + +/** The function prototype for the callback of an AvahiRecordBrowser */ +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); + +/** Browse for records of a type on the local network */ +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); + +/** Get the parent client of an AvahiRecordBrowser object */ +AvahiClient* avahi_record_browser_get_client(AvahiRecordBrowser *); + +/** Cleans up and frees an AvahiRecordBrowser object */ +int avahi_record_browser_free(AvahiRecordBrowser *); + +/** @} */ + +AVAHI_C_DECL_END + +#endif diff --git a/linux/avahi-client/publish.h b/linux/avahi-client/publish.h new file mode 100644 index 0000000..714a689 --- /dev/null +++ b/linux/avahi-client/publish.h @@ -0,0 +1,174 @@ +#ifndef fooclientpublishhfoo +#define fooclientpublishhfoo + +/* $Id: publish.h 1502 2007-07-30 20:12:20Z lennart $ */ + +/*** + This file is part of avahi. + + avahi is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + avahi is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with avahi; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#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> + +/** \file avahi-client/publish.h Publishing Client API */ + +/** \example client-publish-service.c Example how to register a DNS-SD + * service using the client interface to avahi-daemon. It behaves like a network + * printer registering both an IPP and a BSD LPR service. */ + +AVAHI_C_DECL_BEGIN + +/** An entry group object */ +typedef struct AvahiEntryGroup AvahiEntryGroup; + +/** The function prototype for the callback of an AvahiEntryGroup */ +typedef void (*AvahiEntryGroupCallback) ( + AvahiEntryGroup *g, + AvahiEntryGroupState state /**< The new state of the entry group */, + void* userdata /* The arbitrary user data pointer originally passed to avahi_entry_group_new()*/); + +/** @{ \name Construction and destruction */ + +/** Create a new AvahiEntryGroup object */ +AvahiEntryGroup* avahi_entry_group_new( + AvahiClient* c, + AvahiEntryGroupCallback callback /**< This 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. */, + void *userdata /**< This arbitrary user data pointer will be passed to the callback functon */); + +/** Clean up and free an AvahiEntryGroup object */ +int avahi_entry_group_free (AvahiEntryGroup *); + +/** @} */ + +/** @{ \name State */ + +/** Commit an AvahiEntryGroup. The entries in the entry group are now registered on the network. Commiting empty entry groups is considered an error. */ +int avahi_entry_group_commit (AvahiEntryGroup*); + +/** Reset an AvahiEntryGroup. This takes effect immediately. */ +int avahi_entry_group_reset (AvahiEntryGroup*); + +/** Get an AvahiEntryGroup's state */ +int avahi_entry_group_get_state (AvahiEntryGroup*); + +/** Check if an AvahiEntryGroup is empty */ +int avahi_entry_group_is_empty (AvahiEntryGroup*); + +/** Get an AvahiEntryGroup's owning client instance */ +AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*); + +/** @} */ + +/** @{ \name Adding and updating entries */ + +/** 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. */ +int avahi_entry_group_add_service( + AvahiEntryGroup *group, + AvahiIfIndex interface /**< The interface this service shall be announced on. We recommend to pass AVAHI_IF_UNSPEC here, to announce on all interfaces. */, + AvahiProtocol protocol /**< The 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. */, + AvahiPublishFlags flags /**< Usually 0, unless you know what you do */, + const char *name /**< The 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. */, + const char *type /**< The service type for the new service, such as _http._tcp. May not be NULL. */, + const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, + const char *host /**< The 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 */, + uint16_t port /**< The IP port number of this service */, + ...) AVAHI_GCC_SENTINEL; + +/** Add a service, takes an AvahiStringList for TXT records. Arguments have the same meaning as for avahi_entry_group_add_service(). */ +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 /**< The TXT data for this service. You may free this object after calling this function, it is not referenced any further */); + +/** 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. */ +int avahi_entry_group_add_service_subtype( + AvahiEntryGroup *group, + AvahiIfIndex interface /**< The interface this subtype shall be announced on. This should match the value passed for the original avahi_entry_group_add_service() call. */, + AvahiProtocol protocol /**< The protocol this subtype shall be announced with. This should match the value passed for the original avahi_entry_group_add_service() call. */, + AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, + const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, + const char *subtype /**< The new subtype to register for the specified service. May not be NULL. */); + +/** Update a TXT record for an existing service. The service should already be existent in the entry group. */ +int avahi_entry_group_update_service_txt( + AvahiEntryGroup *g, + AvahiIfIndex interface /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */, + AvahiProtocol protocol /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */, + AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, + const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, + const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, + ...) AVAHI_GCC_SENTINEL; + +/** 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. */ +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); + +/** \cond fulldocs */ +/** Add a host/address pair */ +int avahi_entry_group_add_address( + AvahiEntryGroup *group, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiPublishFlags flags, + const char *name /**< The FDQN of the new hostname to register */, + const AvahiAddress *a /**< The address this host name shall map to */); +/** \endcond */ + +/** Add an arbitrary record. I hope you know what you do. */ +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); + +/** @} */ + +AVAHI_C_DECL_END + +#endif |