]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_zeroconf.c
4c41bc6f7f7b1aeae5d388864d1eb6fa6dd9a841
[netatalk.git] / etc / afpd / afp_zeroconf.c
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
2 /*
3  * Author:  Daniel S. Haischt <me@daniel.stefan.haischt.name>
4  * Purpose: Zeroconf facade, that abstracts access to a
5  *          particular Zeroconf implementation
6  * Doc:     http://www.dns-sd.org/
7  *
8  */
9
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13
14 #include "afp_zeroconf.h"
15
16 /*
17  * Global Definitions
18  */
19 #ifdef HAVE_AVAHI
20 struct context *ctx = NULL;
21 #endif
22
23 /*
24  * Functions (actually they are just facades)
25  */
26 void zeroconf_register(int port, const char *hostname)
27 {
28 #if defined (HAVE_AVAHI)
29   LOG(log_debug, logtype_afpd, "Attempting to register with mDNS using Avahi");
30
31         ctx = av_zeroconf_setup(port ? port : AFP_PORT, 
32                                                                                                         (hostname && strlen(hostname) > 0) ? hostname : NULL);
33   av_zeroconf_run(ctx);
34 #endif
35 }
36
37 void zeroconf_register_volume(const char *volname)
38 {
39 #if defined (HAVE_AVAHI)
40   LOG(log_debug, logtype_afpd, "Attempting to register volume with mDNS using Avahi");
41
42         ctx = av_zeroconf_setup(-1, volname);
43
44   av_zeroconf_run(ctx);
45 #endif
46 }
47
48
49 void zeroconf_deregister(void)
50 {
51 #if defined (HAVE_AVAHI)
52   LOG(log_debug, logtype_afpd, "Attempting to de-register mDNS using Avahi");
53   if (ctx)
54     av_zeroconf_shutdown(ctx);
55 #endif
56 }