lookup.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. #ifndef fooclientlookuphfoo
  2. #define fooclientlookuphfoo
  3. /***
  4. This file is part of avahi.
  5. avahi is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU Lesser General Public License as
  7. published by the Free Software Foundation; either version 2.1 of the
  8. License, or (at your option) any later version.
  9. avahi is distributed in the hope that it will be useful, but WITHOUT
  10. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
  12. Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with avahi; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  16. USA.
  17. ***/
  18. #include <inttypes.h>
  19. #include <avahi-common/cdecl.h>
  20. #include <avahi-common/address.h>
  21. #include <avahi-common/strlst.h>
  22. #include <avahi-common/defs.h>
  23. #include <avahi-common/watch.h>
  24. #include <avahi-common/gccmacro.h>
  25. #include <avahi-client/client.h>
  26. /** \file avahi-client/lookup.h Lookup Client API */
  27. /** \example client-browse-services.c Example how to browse for DNS-SD
  28. * services using the client interface to avahi-daemon. */
  29. AVAHI_C_DECL_BEGIN
  30. /** @{ \name Domain Browser */
  31. /** A domain browser object */
  32. typedef struct AvahiDomainBrowser AvahiDomainBrowser;
  33. /** The function prototype for the callback of an AvahiDomainBrowser */
  34. typedef void (*AvahiDomainBrowserCallback) (
  35. AvahiDomainBrowser *b,
  36. AvahiIfIndex interface,
  37. AvahiProtocol protocol,
  38. AvahiBrowserEvent event,
  39. const char *domain,
  40. AvahiLookupResultFlags flags,
  41. void *userdata);
  42. /** Browse for domains on the local network */
  43. AvahiDomainBrowser* avahi_domain_browser_new (
  44. AvahiClient *client,
  45. AvahiIfIndex interface,
  46. AvahiProtocol protocol,
  47. const char *domain,
  48. AvahiDomainBrowserType btype,
  49. AvahiLookupFlags flags,
  50. AvahiDomainBrowserCallback callback,
  51. void *userdata);
  52. /** Get the parent client of an AvahiDomainBrowser object */
  53. AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
  54. /** Cleans up and frees an AvahiDomainBrowser object */
  55. int avahi_domain_browser_free (AvahiDomainBrowser *);
  56. /** @} */
  57. /** @{ \name Service Browser */
  58. /** A service browser object */
  59. typedef struct AvahiServiceBrowser AvahiServiceBrowser;
  60. /** The function prototype for the callback of an AvahiServiceBrowser */
  61. typedef void (*AvahiServiceBrowserCallback) (
  62. AvahiServiceBrowser *b,
  63. AvahiIfIndex interface,
  64. AvahiProtocol protocol,
  65. AvahiBrowserEvent event,
  66. const char *name,
  67. const char *type,
  68. const char *domain,
  69. AvahiLookupResultFlags flags,
  70. void *userdata);
  71. /** Browse for services of a type on the network. In most cases you
  72. * probably want to pass AVAHI_IF_UNSPEC and AVAHI_PROTO_UNSPED in
  73. * interface, resp. protocol to browse on all local networks. The
  74. * specified callback will be called whenever a new service appears
  75. * or is removed from the network. Please note that events may be
  76. * collapsed to minimize traffic (i.e. a REMOVED followed by a NEW for
  77. * the same service data is dropped because redundant). If you want to
  78. * subscribe to service data changes, you should use
  79. * avahi_service_resolver_new() and keep it open, in which case you
  80. * will be notified via AVAHI_RESOLVE_FOUND everytime the service data
  81. * changes. */
  82. AvahiServiceBrowser* avahi_service_browser_new (
  83. AvahiClient *client,
  84. AvahiIfIndex interface, /**< In most cases pass AVAHI_IF_UNSPEC here */
  85. AvahiProtocol protocol, /**< In most cases pass AVAHI_PROTO_UNSPEC here */
  86. const char *type, /**< A service type such as "_http._tcp" */
  87. const char *domain, /**< A domain to browse in. In most cases you want to pass NULL here for the default domain (usually ".local") */
  88. AvahiLookupFlags flags,
  89. AvahiServiceBrowserCallback callback,
  90. void *userdata);
  91. /** Get the parent client of an AvahiServiceBrowser object */
  92. AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
  93. /** Cleans up and frees an AvahiServiceBrowser object */
  94. int avahi_service_browser_free (AvahiServiceBrowser *);
  95. /** @} */
  96. /** \cond fulldocs */
  97. /** A service type browser object */
  98. typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
  99. /** The function prototype for the callback of an AvahiServiceTypeBrowser */
  100. typedef void (*AvahiServiceTypeBrowserCallback) (
  101. AvahiServiceTypeBrowser *b,
  102. AvahiIfIndex interface,
  103. AvahiProtocol protocol,
  104. AvahiBrowserEvent event,
  105. const char *type,
  106. const char *domain,
  107. AvahiLookupResultFlags flags,
  108. void *userdata);
  109. /** Browse for service types on the local network */
  110. AvahiServiceTypeBrowser* avahi_service_type_browser_new (
  111. AvahiClient *client,
  112. AvahiIfIndex interface,
  113. AvahiProtocol protocol,
  114. const char *domain,
  115. AvahiLookupFlags flags,
  116. AvahiServiceTypeBrowserCallback callback,
  117. void *userdata);
  118. /** Get the parent client of an AvahiServiceTypeBrowser object */
  119. AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
  120. /** Cleans up and frees an AvahiServiceTypeBrowser object */
  121. int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
  122. /** \endcond */
  123. /** @{ \name Service Resolver */
  124. /** A service resolver object */
  125. typedef struct AvahiServiceResolver AvahiServiceResolver;
  126. /** The function prototype for the callback of an AvahiServiceResolver */
  127. typedef void (*AvahiServiceResolverCallback) (
  128. AvahiServiceResolver *r,
  129. AvahiIfIndex interface,
  130. AvahiProtocol protocol,
  131. AvahiResolverEvent event,
  132. const char *name,
  133. const char *type,
  134. const char *domain,
  135. const char *host_name,
  136. const AvahiAddress *a,
  137. uint16_t port,
  138. AvahiStringList *txt,
  139. AvahiLookupResultFlags flags,
  140. void *userdata);
  141. /** Create a new service resolver object. Please make sure to pass all
  142. * the service data you received via avahi_service_browser_new()'s
  143. * callback function, especially interface and protocol. The protocol
  144. * argument specifies the protocol (IPv4 or IPv6) to use as transport
  145. * for the queries which are sent out by this resolver. The
  146. * aprotocol argument specifies the adress family (IPv4 or IPv6) of
  147. * the address of the service we are looking for. Generally, on
  148. * "protocol" you should only pass what was supplied to you as
  149. * parameter to your AvahiServiceBrowserCallback. In "aprotocol" you
  150. * should pass what your application code can deal with when
  151. * connecting to the service. Or, more technically speaking: protocol
  152. * specifies if the mDNS queries should be sent as UDP/IPv4
  153. * resp. UDP/IPv6 packets. aprotocol specifies whether the query is for a A
  154. * resp. AAAA resource record. */
  155. AvahiServiceResolver * avahi_service_resolver_new(
  156. AvahiClient *client,
  157. AvahiIfIndex interface, /**< Pass the interface argument you received in AvahiServiceBrowserCallback here. */
  158. AvahiProtocol protocol, /**< Pass the protocol argument you received in AvahiServiceBrowserCallback here. */
  159. const char *name, /**< Pass the name argument you received in AvahiServiceBrowserCallback here. */
  160. const char *type, /**< Pass the type argument you received in AvahiServiceBrowserCallback here. */
  161. const char *domain, /**< Pass the domain argument you received in AvahiServiceBrowserCallback here. */
  162. AvahiProtocol aprotocol, /**< The desired address family of the service address to resolve. AVAHI_PROTO_UNSPEC if your application can deal with both IPv4 and IPv6 */
  163. AvahiLookupFlags flags,
  164. AvahiServiceResolverCallback callback,
  165. void *userdata);
  166. /** Get the parent client of an AvahiServiceResolver object */
  167. AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
  168. /** Free a service resolver object */
  169. int avahi_service_resolver_free(AvahiServiceResolver *r);
  170. /** @} */
  171. /** \cond fulldocs */
  172. /** A service resolver object */
  173. typedef struct AvahiHostNameResolver AvahiHostNameResolver;
  174. /** The function prototype for the callback of an AvahiHostNameResolver */
  175. typedef void (*AvahiHostNameResolverCallback) (
  176. AvahiHostNameResolver *r,
  177. AvahiIfIndex interface,
  178. AvahiProtocol protocol,
  179. AvahiResolverEvent event,
  180. const char *name,
  181. const AvahiAddress *a,
  182. AvahiLookupResultFlags flags,
  183. void *userdata);
  184. /** Create a new hostname resolver object */
  185. AvahiHostNameResolver * avahi_host_name_resolver_new(
  186. AvahiClient *client,
  187. AvahiIfIndex interface,
  188. AvahiProtocol protocol,
  189. const char *name,
  190. AvahiProtocol aprotocol,
  191. AvahiLookupFlags flags,
  192. AvahiHostNameResolverCallback callback,
  193. void *userdata);
  194. /** Get the parent client of an AvahiHostNameResolver object */
  195. AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
  196. /** Free a hostname resolver object */
  197. int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
  198. /** An address resolver object */
  199. typedef struct AvahiAddressResolver AvahiAddressResolver;
  200. /** The function prototype for the callback of an AvahiAddressResolver */
  201. typedef void (*AvahiAddressResolverCallback) (
  202. AvahiAddressResolver *r,
  203. AvahiIfIndex interface,
  204. AvahiProtocol protocol,
  205. AvahiResolverEvent event,
  206. const AvahiAddress *a,
  207. const char *name,
  208. AvahiLookupResultFlags flags,
  209. void *userdata);
  210. /** Create a new address resolver object from an AvahiAddress object */
  211. AvahiAddressResolver* avahi_address_resolver_new(
  212. AvahiClient *client,
  213. AvahiIfIndex interface,
  214. AvahiProtocol protocol,
  215. const AvahiAddress *a,
  216. AvahiLookupFlags flags,
  217. AvahiAddressResolverCallback callback,
  218. void *userdata);
  219. /** Get the parent client of an AvahiAddressResolver object */
  220. AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *);
  221. /** Free a AvahiAddressResolver resolver object */
  222. int avahi_address_resolver_free(AvahiAddressResolver *r);
  223. /** \endcond */
  224. /** @{ \name Record Browser */
  225. /** A record browser object */
  226. typedef struct AvahiRecordBrowser AvahiRecordBrowser;
  227. /** The function prototype for the callback of an AvahiRecordBrowser */
  228. typedef void (*AvahiRecordBrowserCallback) (
  229. AvahiRecordBrowser *b,
  230. AvahiIfIndex interface,
  231. AvahiProtocol protocol,
  232. AvahiBrowserEvent event,
  233. const char *name,
  234. uint16_t clazz,
  235. uint16_t type,
  236. const void *rdata,
  237. size_t size,
  238. AvahiLookupResultFlags flags,
  239. void *userdata);
  240. /** Browse for records of a type on the local network */
  241. AvahiRecordBrowser* avahi_record_browser_new(
  242. AvahiClient *client,
  243. AvahiIfIndex interface,
  244. AvahiProtocol protocol,
  245. const char *name,
  246. uint16_t clazz,
  247. uint16_t type,
  248. AvahiLookupFlags flags,
  249. AvahiRecordBrowserCallback callback,
  250. void *userdata);
  251. /** Get the parent client of an AvahiRecordBrowser object */
  252. AvahiClient* avahi_record_browser_get_client(AvahiRecordBrowser *);
  253. /** Cleans up and frees an AvahiRecordBrowser object */
  254. int avahi_record_browser_free(AvahiRecordBrowser *);
  255. /** @} */
  256. AVAHI_C_DECL_END
  257. #endif