- err = SLPOpen("en", SLP_FALSE, &hslp);
- if (err != SLP_OK) {
- LOG(log_error, logtype_afpd, "DSIConfigInit: Error opening SRVLOC handle");
- goto srvloc_reg_err;
- }
-
- /* XXX We don't want to tack on the port number if we don't have to. Why?
- * Well, this seems to break MacOS < 10. If the user _really_ wants to
- * use a non-default port, they can, but be aware, this server might not
- * show up int the Network Browser. */
- afpovertcp = getservbyname("afpovertcp", "tcp");
- srvloc_hostname = (options->server ? options->server : options->hostname);
- if (afpovertcp != NULL) {
- afp_port = afpovertcp->s_port;
- }
- if (strlen(srvloc_hostname) > (sizeof(srvloc_url) - strlen(inet_ntoa(dsi->server.sin_addr)) - 21)) {
- LOG(log_error, logtype_afpd, "DSIConfigInit: Hostname is too long for SRVLOC");
- goto srvloc_reg_err;
- }
- if (dsi->server.sin_port == afp_port) {
- sprintf(srvloc_url, "afp://%s/?NAME=%s", inet_ntoa(dsi->server.sin_addr), srvloc_hostname);
- }
- else {
- sprintf(srvloc_url, "afp://%s:%d/?NAME=%s", inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port), srvloc_hostname);
- }
-
- err = SLPReg(hslp,
- srvloc_url,
- SLP_LIFETIME_MAXIMUM,
- "",
- "",
- SLP_TRUE,
- SRVLOC_callback,
- &callbackerr);
- if (err != SLP_OK) {
- LOG(log_error, logtype_afpd, "DSIConfigInit: Error registering %s with SRVLOC", srvloc_url);
- goto srvloc_reg_err;
- }
-
- if (callbackerr != SLP_OK) {
- LOG(log_error, logtype_afpd, "DSIConfigInit: Error in callback trying to register %s with SRVLOC", srvloc_url);
- goto srvloc_reg_err;
- }
-
- LOG(log_info, logtype_afpd, "Sucessfully registered %s with SRVLOC", srvloc_url);
+ dsi->srvloc_url[0] = '\0'; /* Mark that we haven't registered. */
+ if (!(options->flags & OPTION_NOSLP)) {
+ err = SLPOpen("en", SLP_FALSE, &hslp);
+ if (err != SLP_OK) {
+ LOG(log_error, logtype_afpd, "DSIConfigInit: Error opening SRVLOC handle");
+ goto srvloc_reg_err;
+ }
+
+ /* XXX We don't want to tack on the port number if we don't have to.
+ * Why?
+ * Well, this seems to break MacOS < 10. If the user _really_ wants to
+ * 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 = afpovertcp->s_port;
+ }
+ /* 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);
+ srvloc_hostname = srvloc_encode(options, (options->server ? options->server : options->hostname));
+
+ if (strlen(srvloc_hostname) > (sizeof(dsi->srvloc_url) - strlen(hostname) - 21)) {
+ LOG(log_error, logtype_afpd, "DSIConfigInit: Hostname is too long for SRVLOC");
+ dsi->srvloc_url[0] = '\0';
+ goto srvloc_reg_err;
+ }
+ if ((p) || dsi->server.sin_port == afp_port) {
+ sprintf(dsi->srvloc_url, "afp://%s/?NAME=%s", hostname, srvloc_hostname);
+ }
+ else {
+ sprintf(dsi->srvloc_url, "afp://%s:%d/?NAME=%s", hostname, ntohs(dsi->server.sin_port), srvloc_hostname);
+ }
+
+ err = SLPReg(hslp,
+ dsi->srvloc_url,
+ SLP_LIFETIME_MAXIMUM,
+ "afp",
+ "",
+ SLP_TRUE,
+ SRVLOC_callback,
+ &callbackerr);
+ if (err != SLP_OK) {
+ LOG(log_error, logtype_afpd, "DSIConfigInit: Error registering %s with SRVLOC", dsi->srvloc_url);
+ dsi->srvloc_url[0] = '\0';
+ goto srvloc_reg_err;
+ }
+
+ if (callbackerr != SLP_OK) {
+ LOG(log_error, logtype_afpd, "DSIConfigInit: Error in callback trying to register %s with SRVLOC", dsi->srvloc_url);
+ dsi->srvloc_url[0] = '\0';
+ goto srvloc_reg_err;
+ }
+
+ LOG(log_info, logtype_afpd, "Sucessfully registered %s with SRVLOC", dsi->srvloc_url);