]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 409] Add DNS-SD/Rendezvous to ntpd, from Andre Masella
authorHarlan Stenn <stenn@ntp.org>
Wed, 27 Apr 2005 08:09:54 +0000 (04:09 -0400)
committerHarlan Stenn <stenn@ntp.org>
Wed, 27 Apr 2005 08:09:54 +0000 (04:09 -0400)
bk: 426f48d2Z1wrXWBChOsHxJGI4R1QdQ

configure.ac
ntpd/ntpd.c

index 4bbdf33d0f2ce8b6dd1fa65a3d26521f7c0ab281..dbb28b5d00d91737035bd6d154b00d93b05a6e8c 100644 (file)
@@ -315,7 +315,17 @@ esac
 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
 
 AC_HEADER_STDC
-AC_CHECK_HEADERS(bstring.h errno.h fcntl.h ieeefp.h math.h)
+AC_CHECK_HEADERS(bstring.h)
+AC_CHECK_HEADER(dns_sd.h,
+       [AC_CHECK_LIB(dns_sd,
+                       DNSServiceRegister,
+                       [AC_DEFINE(HAVE_DNSREGISTRATION, 1,
+                               [Use Rendezvous/DNS-SD registration])])])
+case "$ac_cv_lib_dns_sd_DNSServiceRegister" in
+ yes) LIBS="-ldns_sd $LIBS" ;;
+esac
+AC_CHECK_HEADERS(errno.h fcntl.h ieeefp.h math.h)
+
 # HMS: Lame, but fast.
 if test -f /etc/redhat-release
 then
index 43360cbb569da46bef6084b9bfd89f457351db34..a579d910613e34360e390a4449515eb3f03f59f3 100644 (file)
 # define SIGDIE4       SIGTERM
 #endif /* SYS_WINNT */
 
+#ifdef HAVE_DNSREGISTRATION
+#include <dns_sd.h>
+DNSServiceRef mdns;
+#endif
+
 /*
  * Scheduling priority we run at
  */
@@ -462,6 +467,13 @@ ntpdmain(
        get_systime(&now);
        SRANDOM((int)(now.l_i * now.l_uf));
 
+#ifdef HAVE_DNSREGISTRATION
+       msyslog(LOG_INFO, "Attemping to register mDNS\n");
+       if ( DNSServiceRegister (&mdns, 0, 0, NULL, "_ntp._udp", NULL, NULL, htons(NTP_PORT), 0, NULL, NULL, NULL) != kDNSServiceErr_NoError ) {
+               msyslog(LOG_ERR, "Unable to register mDNS\n");
+       }
+#endif
+
 #if !defined(VMS)
 # ifndef NODETACH
        /*
@@ -961,6 +973,10 @@ finish(
 {
 
        msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig);
+#ifdef HAVE_DNSREGISTRATION
+       if (mdns != NULL)
+       DNSServiceRefDeallocate(mdns);
+#endif
 
        switch (sig)
        {