0ae0d11
diff -up dhcp-4.3.0/configure.ac.sd-daemon dhcp-4.3.0/configure.ac
0ae0d11
--- dhcp-4.3.0/configure.ac.sd-daemon	2014-03-18 15:17:11.000000000 +0100
0ae0d11
+++ dhcp-4.3.0/configure.ac	2014-03-18 15:35:47.982182345 +0100
0ae0d11
@@ -677,6 +677,17 @@ if test x$ldap = xyes || test x$ldapcryp
0ae0d11
     fi
0ae0d11
 fi
0ae0d11
 
0ae0d11
+AC_ARG_WITH(systemd,
0ae0d11
+        AC_HELP_STRING([--with-systemd],
0ae0d11
+                       [enable sending status notifications to systemd daemon (default is no)]),
0ae0d11
+        [systemd=$withval],
0ae0d11
+        [systemd=no])
0ae0d11
+
0ae0d11
+if test x$systemd = xyes ; then
3dbffba
+   AC_CHECK_LIB(systemd, sd_notifyf, ,
3dbffba
+                AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
0ae0d11
+fi
0ae0d11
+
0ae0d11
 # Append selected warning levels to CFLAGS before substitution (but after
0ae0d11
 # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
0ae0d11
 CFLAGS="$CFLAGS $STD_CWARNINGS"
0ae0d11
diff -up dhcp-4.3.0/relay/dhcrelay.c.sd-daemon dhcp-4.3.0/relay/dhcrelay.c
0ae0d11
--- dhcp-4.3.0/relay/dhcrelay.c.sd-daemon	2014-03-18 15:17:11.000000000 +0100
0ae0d11
+++ dhcp-4.3.0/relay/dhcrelay.c	2014-03-18 15:35:42.063264999 +0100
0ae0d11
@@ -36,6 +36,10 @@
0ae0d11
    int keep_capabilities = 0;
0ae0d11
 #endif
0ae0d11
 
3dbffba
+#ifdef HAVE_LIBSYSTEMD
0ae0d11
+#include <systemd/sd-daemon.h>
0ae0d11
+#endif
0ae0d11
+
0ae0d11
 TIME default_lease_time = 43200; /* 12 hours... */
0ae0d11
 TIME max_lease_time = 86400; /* 24 hours... */
0ae0d11
 struct tree_cache *global_options[256];
0ae0d11
@@ -624,6 +628,14 @@ main(int argc, char **argv) {
0ae0d11
 	}
0ae0d11
 #endif
0ae0d11
 
3dbffba
+#ifdef HAVE_LIBSYSTEMD
0ae0d11
+        /* We are ready to process incomming packets. Let's notify systemd */
0ae0d11
+        sd_notifyf(0, "READY=1\n"
0ae0d11
+                   "STATUS=Dispatching packets...\n"
0ae0d11
+                   "MAINPID=%lu",
0ae0d11
+                   (unsigned long) getpid());
0ae0d11
+#endif
0ae0d11
+
0ae0d11
 	/* Start dispatching packets and timeouts... */
0ae0d11
 	dispatch();
0ae0d11
 
0ae0d11
diff -up dhcp-4.3.0/server/dhcpd.c.sd-daemon dhcp-4.3.0/server/dhcpd.c
0ae0d11
--- dhcp-4.3.0/server/dhcpd.c.sd-daemon	2014-03-18 15:17:11.000000000 +0100
0ae0d11
+++ dhcp-4.3.0/server/dhcpd.c	2014-03-18 15:34:59.207863458 +0100
0ae0d11
@@ -54,6 +54,10 @@ static const char url [] =
0ae0d11
 
0ae0d11
 #include "trace.h"
0ae0d11
 
3dbffba
+#ifdef HAVE_LIBSYSTEMD
0ae0d11
+#include <systemd/sd-daemon.h>
0ae0d11
+#endif
0ae0d11
+
0ae0d11
 #ifndef UNIT_TEST
0ae0d11
 static void usage(void);
0ae0d11
 #endif
0ae0d11
@@ -792,6 +796,13 @@ main(int argc, char **argv) {
0ae0d11
 
0ae0d11
 	TRACE(DHCPD_MAIN());
0ae0d11
 
3dbffba
+#ifdef HAVE_LIBSYSTEMD
0ae0d11
+        /* We are ready to process incomming packets. Let's notify systemd */
0ae0d11
+        sd_notifyf(0, "READY=1\n"
0ae0d11
+                   "STATUS=Dispatching packets...\n"
0ae0d11
+                   "MAINPID=%lu",
0ae0d11
+                   (unsigned long) getpid());
0ae0d11
+#endif
0ae0d11
 	/*
0ae0d11
 	 * Receive packets and dispatch them...
0ae0d11
 	 * dispatch() will never return.