7406750
diff -up dhcp-4.3.3b1/configure.ac.sd_notify dhcp-4.3.3b1/configure.ac
7406750
--- dhcp-4.3.3b1/configure.ac.sd_notify	2015-08-10 11:57:24.955325674 +0200
7406750
+++ dhcp-4.3.3b1/configure.ac	2015-08-10 11:58:20.024113933 +0200
7406750
@@ -777,6 +777,17 @@ if test x$ldap = xyes || test x$ldapcryp
7406750
     AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
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"
7406750
diff -up dhcp-4.3.3b1/relay/dhcrelay.c.sd_notify dhcp-4.3.3b1/relay/dhcrelay.c
7406750
--- dhcp-4.3.3b1/relay/dhcrelay.c.sd_notify	2015-08-10 11:57:24.901325882 +0200
7406750
+++ dhcp-4.3.3b1/relay/dhcrelay.c	2015-08-10 11:57:24.956325670 +0200
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];
7406750
@@ -627,6 +631,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
 
7406750
diff -up dhcp-4.3.3b1/server/dhcpd.c.sd_notify dhcp-4.3.3b1/server/dhcpd.c
7406750
--- dhcp-4.3.3b1/server/dhcpd.c.sd_notify	2015-08-10 11:57:24.937325743 +0200
7406750
+++ dhcp-4.3.3b1/server/dhcpd.c	2015-08-10 11:57:24.956325670 +0200
7406750
@@ -58,6 +58,10 @@ gid_t set_gid = 0;
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
7406750
@@ -820,6 +824,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.