]> arthur.barton.de Git - netatalk.git/commitdiff
fixes
authorFrank Lahm <franklahm@googlemail.com>
Sun, 20 Jun 2010 10:01:56 +0000 (12:01 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Sun, 20 Jun 2010 10:01:56 +0000 (12:01 +0200)
etc/afpd/afp_config.c
etc/afpd/afp_zeroconf.c
etc/afpd/afp_zeroconf.h
macros/zeroconf.m4

index 7f982c3341a1765dbdb3a99066148187209671ac..d53dee14d4f637165c98c8804593596e453ca375 100644 (file)
@@ -465,9 +465,8 @@ srvloc_reg_err:
 #endif /* USE_SRVLOC */
 
 #ifdef USE_ZEROCONF
-     struct servent *afpovertcp;
-     int afp_port = 548;
-     char *hostname = NULL;
+    uint afp_port;
+    const char *hostname = NULL;
 
     dsi->zeroconf_registered = 0; /*  Mark that we haven't registered.  */
 
@@ -478,26 +477,21 @@ srvloc_reg_err:
           * use a non-default port, they can, but be aware, this server might
           * not show up int the Network Browser.
           */
-        afpovertcp = getservbyname("afpovertcp", "tcp");
-        if (afpovertcp != NULL) {
-             afp_port = ntohs(afpovertcp->s_port);
-        }
+        afp_port = getip_port((struct sockaddr *)&dsi->server);
 
         /* If specified use the FQDN to register with srvloc, otherwise use IP. */
         p = NULL;
         if (options->fqdn) {
             hostname = options->fqdn;
             p = strchr(hostname, ':');
-        }      
-        else 
-            hostname = inet_ntoa(dsi->server.sin_addr);
-
-        if (!(options->flags & OPTION_NOSLP)) {
-            zeroconf_register(afp_port, hostname);
-            dsi->zeroconf_registered = 1; /*  Mark that we have registered.  */
+        }  else {
+            hostname = getip_string((struct sockaddr *)&dsi->server);
         }
+
+        zeroconf_register(afp_port, hostname);
+        dsi->zeroconf_registered = 1; /*  Mark that we have registered.  */
+        config->server_cleanup = dsi_cleanup;
     }
-    config->server_cleanup = dsi_cleanup;
 #endif /* USE_ZEROCONF */
 
     config->fd = dsi->serversock;
index d5149162a1cc63bf0a4b7625afeb0b855ac14444..4bc2361757da33699c69391351d417e7387f1894 100644 (file)
@@ -23,7 +23,7 @@ struct context *ctx = NULL;
 /*
  * Functions (actually they are just facades)
  */
-void zeroconf_register(int port, char *hostname)
+void zeroconf_register(int port, const char *hostname)
 {
 #if defined (HAVE_AVAHI)
   LOG(log_info, logtype_afpd, "Attempting to register with mDNS using Avahi\n");
index 895376f30f4eb4a2ce46536bc963223ebf6d33a9..5492bac5fdce4eef9a7d9fc8346945884ac7d5aa 100644 (file)
@@ -13,7 +13,7 @@
 #include <netinet/in.h> /* htons() */
 #include <atalk/logger.h>
 
-#ifdef (HAVE_AVAHI)
+#ifdef HAVE_AVAHI
 #include "afp_avahi.h"
 #endif
 
 /*
  * registers the ntpd service with a particular Zerconf implemenation.
  */
-void zeroconf_register(int port, char *hostname);
+void zeroconf_register(int port, const char *hostname);
 
 /*
  * de-registers the ntpd service with a particular Zerconf implemenation.
  */
 void zeroconf_deregister(void);
 
-#endif AFPD_ZEROCONF_H
+#endif /* AFPD_ZEROCONF_H */
index d9fe026b691f5e17888201f1524daba5dc843c2e..788a193038fb217369d203bf581febb6766c4d11 100644 (file)
@@ -1,7 +1,6 @@
 dnl Check for optional Zeroconf support
 
 AC_DEFUN([NETATALK_ZEROCONF], [
-
        ZEROCONF_LIBS=""
        ZEROCONF_CFLAGS=""
        found_zeroconf=no
@@ -17,7 +16,6 @@ AC_DEFUN([NETATALK_ZEROCONF], [
     [[ -n "$atalk_libname" ]] || AC_MSG_ERROR([internal error, atalk_libname undefined])
 
        if test "x$zeroconf" != "xno"; then
-
                savedcppflags="$CPPFLAGS"
                savedldflags="$LDFLAGS"
 
@@ -28,11 +26,14 @@ AC_DEFUN([NETATALK_ZEROCONF], [
                fi
 
     # mDNS support using Avahi
-    AC_CHECK_HEADER(avahi-client/client.h,
-      [AC_CHECK_LIB(avahi-client,
-        avahi_client_new,
-                               [AC_DEFINE(USE_ZEROCONF, 1,
-          [Use DNS-SD registration])])])
+    AC_CHECK_HEADER(
+        avahi-client/client.h,
+        AC_CHECK_LIB(
+           avahi-client,
+           avahi_client_new,
+           AC_DEFINE(USE_ZEROCONF, 1, [Use DNS-SD registration]))
+    )
+
     case "$ac_cv_lib_avahi_client_avahi_client_new" in
       yes)
       PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6 ])