1 #ifndef fooclientpublishhfoo 2 #define fooclientpublishhfoo 3 4 /*** 5 This file is part of avahi. 6 7 avahi is free software; you can redistribute it and/or modify it 8 under the terms of the GNU Lesser General Public License as 9 published by the Free Software Foundation; either version 2.1 of the 10 License, or (at your option) any later version. 11 12 avahi is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 15 Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with avahi; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 USA. 21 ***/ 22 23 #include <inttypes.h> 24 25 #include <avahi-common/cdecl.h> 26 #include <avahi-common/address.h> 27 #include <avahi-common/strlst.h> 28 #include <avahi-common/defs.h> 29 #include <avahi-common/watch.h> 30 #include <avahi-common/gccmacro.h> 31 32 #include <avahi-client/client.h> 33 34 /** \file avahi-client/publish.h Publishing Client API */ 35 36 /** \example client-publish-service.c Example how to register a DNS-SD 37 * service using the client interface to avahi-daemon. It behaves like a network 38 * printer registering both an IPP and a BSD LPR service. */ 39 40 AVAHI_C_DECL_BEGIN 41 42 /** An entry group object */ 43 typedef struct AvahiEntryGroup AvahiEntryGroup; 44 45 /** The function prototype for the callback of an AvahiEntryGroup */ 46 typedef void (*AvahiEntryGroupCallback) ( 47 AvahiEntryGroup *g, 48 AvahiEntryGroupState state /**< The new state of the entry group */, 49 void* userdata /* The arbitrary user data pointer originally passed to avahi_entry_group_new()*/); 50 51 /** @{ \name Construction and destruction */ 52 53 /** Create a new AvahiEntryGroup object */ 54 AvahiEntryGroup* avahi_entry_group_new( 55 AvahiClient* c, 56 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. */, 57 void *userdata /**< This arbitrary user data pointer will be passed to the callback functon */); 58 59 /** Clean up and free an AvahiEntryGroup object */ 60 int avahi_entry_group_free (AvahiEntryGroup *); 61 62 /** @} */ 63 64 /** @{ \name State */ 65 66 /** Commit an AvahiEntryGroup. The entries in the entry group are now registered on the network. Commiting empty entry groups is considered an error. */ 67 int avahi_entry_group_commit (AvahiEntryGroup*); 68 69 /** Reset an AvahiEntryGroup. This takes effect immediately. */ 70 int avahi_entry_group_reset (AvahiEntryGroup*); 71 72 /** Get an AvahiEntryGroup's state */ 73 int avahi_entry_group_get_state (AvahiEntryGroup*); 74 75 /** Check if an AvahiEntryGroup is empty */ 76 int avahi_entry_group_is_empty (AvahiEntryGroup*); 77 78 /** Get an AvahiEntryGroup's owning client instance */ 79 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*); 80 81 /** @} */ 82 83 /** @{ \name Adding and updating entries */ 84 85 /** 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. */ 86 int avahi_entry_group_add_service( 87 AvahiEntryGroup *group, 88 AvahiIfIndex interface /**< The interface this service shall be announced on. We recommend to pass AVAHI_IF_UNSPEC here, to announce on all interfaces. */, 89 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. */, 90 AvahiPublishFlags flags /**< Usually 0, unless you know what you do */, 91 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. */, 92 const char *type /**< The service type for the new service, such as _http._tcp. May not be NULL. */, 93 const char *domain /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */, 94 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 */, 95 uint16_t port /**< The IP port number of this service */, 96 ...) AVAHI_GCC_SENTINEL; 97 98 /** Add a service, takes an AvahiStringList for TXT records. Arguments have the same meaning as for avahi_entry_group_add_service(). */ 99 int avahi_entry_group_add_service_strlst( 100 AvahiEntryGroup *group, 101 AvahiIfIndex interface, 102 AvahiProtocol protocol, 103 AvahiPublishFlags flags, 104 const char *name, 105 const char *type, 106 const char *domain, 107 const char *host, 108 uint16_t port, 109 AvahiStringList *txt /**< The TXT data for this service. You may free this object after calling this function, it is not referenced any further */); 110 111 /** 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. */ 112 int avahi_entry_group_add_service_subtype( 113 AvahiEntryGroup *group, 114 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. */, 115 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. */, 116 AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, 117 const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, 118 const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, 119 const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, 120 const char *subtype /**< The new subtype to register for the specified service. May not be NULL. */); 121 122 /** Update a TXT record for an existing service. The service should already be existent in the entry group. */ 123 int avahi_entry_group_update_service_txt( 124 AvahiEntryGroup *g, 125 AvahiIfIndex interface /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */, 126 AvahiProtocol protocol /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */, 127 AvahiPublishFlags flags /**< Only != 0 if you really know what you do */, 128 const char *name /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, 129 const char *type /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */, 130 const char *domain /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */, 131 ...) AVAHI_GCC_SENTINEL; 132 133 /** 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. */ 134 int avahi_entry_group_update_service_txt_strlst( 135 AvahiEntryGroup *g, 136 AvahiIfIndex interface, 137 AvahiProtocol protocol, 138 AvahiPublishFlags flags, 139 const char *name, 140 const char *type, 141 const char *domain, 142 AvahiStringList *strlst); 143 144 /** \cond fulldocs */ 145 /** Add a host/address pair */ 146 int avahi_entry_group_add_address( 147 AvahiEntryGroup *group, 148 AvahiIfIndex interface, 149 AvahiProtocol protocol, 150 AvahiPublishFlags flags, 151 const char *name /**< The FDQN of the new hostname to register */, 152 const AvahiAddress *a /**< The address this host name shall map to */); 153 /** \endcond */ 154 155 /** Add an arbitrary record. I hope you know what you do. */ 156 int avahi_entry_group_add_record( 157 AvahiEntryGroup *group, 158 AvahiIfIndex interface, 159 AvahiProtocol protocol, 160 AvahiPublishFlags flags, 161 const char *name, 162 uint16_t clazz, 163 uint16_t type, 164 uint32_t ttl, 165 const void *rdata, 166 size_t size); 167 168 /** @} */ 169 170 AVAHI_C_DECL_END 171 172 #endif 173