]> arthur.barton.de Git - netatalk.git/commitdiff
SLP support added (Joe Clarke)
authorrufustfirefly <rufustfirefly>
Mon, 17 Sep 2001 13:41:24 +0000 (13:41 +0000)
committerrufustfirefly <rufustfirefly>
Mon, 17 Sep 2001 13:41:24 +0000 (13:41 +0000)
ChangeLog
acconfig.h
configure.in
etc/afpd/afp_config.c

index a3c3f68b5691e5c7b6f3c7aedd5eb650498ed5c5..4c8839e06b4c5c7ef0f5ad35618e43bb0dc17832 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
 
+2001-09-17  jeff b  <jeff@univrel.pr.uconn.edu>
+
+       * acconfig.h, configure.in, etc/afpd/afp_config.c: SLP
+       support added (Joe Clarke)
+
 2001-09-14  jeff b  <jeff@univrel.pr.uconn.edu>
 
        * sys/netatalk/endian.h: fix from Robert Cohen
@@ -11,8 +16,8 @@
 
 2001-09-10  joe c   <marcus@marcuscom.com>
 
-    * libatalk/util/getiface.c:
-       up the new interface by one each time instead of IFACE_NUM
+       * libatalk/util/getiface.c: up the new interface by one
+       each time instead of IFACE_NUM
 
 2001-09-10  jeff b  <jeff@univrel.pr.uconn.edu>
 
index 16bab5d0beaa61dcba7ebce7d08135cb27d4747b..943cc4cb9ba39fede437b7887002d451eb8a5b30 100644 (file)
@@ -40,6 +40,7 @@
 #undef USE_FLOCK_LOCKS
 #undef USE_LASTDID
 #undef USE_PAM
+#undef USE_SRVLOC
 #undef USE_MOUNT_H
 #undef USE_OLD_RQUOTA
 #undef USE_UFS_QUOTA_H
index da60aa2064c11fd82e5d65ecbc1957adf6828148..6d37315273d411de6f5490c3376ba97c12c09d5a 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.103 2001-09-07 13:44:37 rufustfirefly Exp $
+dnl $Id: configure.in,v 1.104 2001-09-17 13:41:24 rufustfirefly Exp $
 dnl configure.in for netatalk
 
 AC_INIT(bin/adv1tov2/adv1tov2.c)
@@ -317,6 +317,27 @@ AC_ARG_WITH(message-dir,
                AC_SUBST(SERVERTEXT)
 )
 
+AC_ARG_ENABLE(srvloc,
+       [  --enable-srvloc         Turn on Server Location Protocol support EXPERIMENTAL)],
+       srvloc=$enableval,
+       srvloc=no
+)
+
+dnl Conditional for optional server location protocol support (used by OS X)
+AM_CONDITIONAL(USE_SRVLOC, test "x$srvloc" != "xno")
+if test "x$srvloc" != "xno"; then
+    for slpdir in "" $srvloc /usr /usr/local ; do
+               if test -f "$slpdir/include/slp.h" ; then
+                       LDFLAGS="$LDFLAGS -L$slpdir/lib -lslp"
+                       CFLAGS="$CFLAGS -I$slpdir/include"
+               AC_CHECK_LIB(slp,SLPOpen)
+               AC_CHECK_FUNCS(SLPReg SLPDereg SLPClose)
+               AC_DEFINE(USE_SRVLOC, 1)
+                       break
+               fi
+       done
+fi
+
 AC_CHECK_LIB(pam, pam_start,
        AC_DEFINE(USE_PAM, 1)
        LIBS="$LIBS -lpam"
index eda0d7dfa7fbc6641545c79b0f926fb8ccd0dfbb..58f1b15e7eef9aeaad026570415d9de92e3cbff7 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: afp_config.c,v 1.4 2001-09-06 20:00:59 rufustfirefly Exp $
+ * $Id: afp_config.c,v 1.5 2001-09-17 13:41:26 rufustfirefly Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -44,6 +44,10 @@ char *strchr (), *strrchr ();
 #include <atalk/afp.h>
 #include <atalk/compat.h>
 #include <atalk/server_child.h>
+#ifdef USE_SRVLOC
+#include <slp.h>
+static char srvloc_url[512];
+#endif
 
 #include "globals.h"
 #include "afp_config.h"
@@ -89,6 +93,43 @@ void configfree(AFPConfig *configs, const AFPConfig *config)
   }
 }
 
+#ifdef USE_SRVLOC
+static void SRVLOC_callback(SLPHandle hslp, SLPError errcode, void *cookie) {
+       *(SLPError*)cookie = errcode;
+}
+#endif
+
+#ifdef USE_SRVLOC
+static void dsi_cleanup(const AFPConfig *config)
+{
+  SLPError err;
+  SLPError callbackerr;
+  SLPHandle hslp;
+  err = SLPOpen("en", SLP_FALSE, &hslp);
+  if (err != SLP_OK) {
+    syslog(LOG_ERR, "Error opening SRVLOC handle");
+    goto srvloc_dereg_err;
+  } 
+
+  err = SLPDereg(hslp,
+                 srvloc_url,
+                 SRVLOC_callback,
+                                &callbackerr);
+  if (err != SLP_OK) {
+         syslog(LOG_ERR, "Error unregistering %s from SRVLOC", srvloc_url);
+         goto srvloc_dereg_err;
+  }
+
+  if (callbackerr != SLP_OK) {
+    syslog(LOG_ERR, "Error in callback while trying to unregister %s from SRVLOC (%i)", srvloc_url, callbackerr);
+       goto srvloc_dereg_err;
+  }
+
+  srvloc_dereg_err:
+    SLPClose(hslp);
+}
+#endif
+
 #ifndef NO_DDP
 static void asp_cleanup(const AFPConfig *config)
 {
@@ -232,6 +273,11 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
   AFPConfig *config;
   DSI *dsi;
   char *p, *q;
+#ifdef USE_SRVLOC
+  SLPError err;
+  SLPError callbackerr;
+  SLPHandle hslp;
+#endif
 
   if ((config = (AFPConfig *) calloc(1, sizeof(AFPConfig))) == NULL) {
     syslog( LOG_ERR, "DSIConfigInit: malloc(config): %m" );
@@ -257,6 +303,40 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
           dsi->serversock, VERSION);
   }
 
+#ifdef USE_SRVLOC
+  err = SLPOpen("en", SLP_FALSE, &hslp);
+  if (err != SLP_OK) {
+         syslog(LOG_ERR, "Error opening SRVLOC handle");
+         goto srvloc_reg_err;
+  }
+
+  snprintf(srvloc_url, sizeof(srvloc_url), "afp://%s:%d?NAME=%s", inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port), options->hostname);
+
+  err = SLPReg(hslp,
+               srvloc_url,
+                          SLP_LIFETIME_MAXIMUM,
+                          "afp:",
+                          "",
+                          SLP_TRUE,
+                          SRVLOC_callback,
+                          &callbackerr);
+  if (err != SLP_OK) {
+         syslog(LOG_ERR, "Error registering %s with SRVLOC", srvloc_url);
+         goto srvloc_reg_err;
+  }
+
+  if (callbackerr != SLP_OK) {
+         syslog(LOG_ERR, "Error in callback trying to register %s with SRVLOC", srvloc_url);
+         goto srvloc_reg_err;
+  }
+
+  syslog(LOG_INFO, "Sucessfully registered %s with SRVLOC", srvloc_url);
+
+  srvloc_reg_err:
+    SLPClose(hslp);
+#endif
+
+
   config->fd = dsi->serversock;
   config->obj.handle = dsi;
   config->obj.config = config;
@@ -273,6 +353,9 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
   (*refcount)++;
 
   config->server_start = dsi_start;
+#ifdef USE_SRVLOC
+  config->server_cleanup = dsi_cleanup;
+#endif
   return config;
 }