740675
diff -up dhcp-4.3.3b1/configure.ac.sd_notify dhcp-4.3.3b1/configure.ac
740675
--- dhcp-4.3.3b1/configure.ac.sd_notify	2015-08-10 11:57:24.955325674 +0200
740675
+++ dhcp-4.3.3b1/configure.ac	2015-08-10 11:58:20.024113933 +0200
740675
@@ -777,6 +777,17 @@ if test x$ldap = xyes || test x$ldapcryp
740675
     AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
0ae0d1
 fi
0ae0d1
 
0ae0d1
+AC_ARG_WITH(systemd,
0ae0d1
+        AC_HELP_STRING([--with-systemd],
0ae0d1
+                       [enable sending status notifications to systemd daemon (default is no)]),
0ae0d1
+        [systemd=$withval],
0ae0d1
+        [systemd=no])
0ae0d1
+
0ae0d1
+if test x$systemd = xyes ; then
3dbffb
+   AC_CHECK_LIB(systemd, sd_notifyf, ,
3dbffb
+                AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
0ae0d1
+fi
0ae0d1
+
0ae0d1
 # Append selected warning levels to CFLAGS before substitution (but after
0ae0d1
 # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
0ae0d1
 CFLAGS="$CFLAGS $STD_CWARNINGS"
740675
diff -up dhcp-4.3.3b1/relay/dhcrelay.c.sd_notify dhcp-4.3.3b1/relay/dhcrelay.c
740675
--- dhcp-4.3.3b1/relay/dhcrelay.c.sd_notify	2015-08-10 11:57:24.901325882 +0200
740675
+++ dhcp-4.3.3b1/relay/dhcrelay.c	2015-08-10 11:57:24.956325670 +0200
0ae0d1
@@ -36,6 +36,10 @@
0ae0d1
    int keep_capabilities = 0;
0ae0d1
 #endif
0ae0d1
 
3dbffb
+#ifdef HAVE_LIBSYSTEMD
0ae0d1
+#include <systemd/sd-daemon.h>
0ae0d1
+#endif
0ae0d1
+
0ae0d1
 TIME default_lease_time = 43200; /* 12 hours... */
0ae0d1
 TIME max_lease_time = 86400; /* 24 hours... */
0ae0d1
 struct tree_cache *global_options[256];
740675
@@ -627,6 +631,14 @@ main(int argc, char **argv) {
0ae0d1
 	}
0ae0d1
 #endif
0ae0d1
 
3dbffb
+#ifdef HAVE_LIBSYSTEMD
0ae0d1
+        /* We are ready to process incomming packets. Let's notify systemd */
0ae0d1
+        sd_notifyf(0, "READY=1\n"
0ae0d1
+                   "STATUS=Dispatching packets...\n"
0ae0d1
+                   "MAINPID=%lu",
0ae0d1
+                   (unsigned long) getpid());
0ae0d1
+#endif
0ae0d1
+
0ae0d1
 	/* Start dispatching packets and timeouts... */
0ae0d1
 	dispatch();
0ae0d1
 
740675
diff -up dhcp-4.3.3b1/server/dhcpd.c.sd_notify dhcp-4.3.3b1/server/dhcpd.c
740675
--- dhcp-4.3.3b1/server/dhcpd.c.sd_notify	2015-08-10 11:57:24.937325743 +0200
740675
+++ dhcp-4.3.3b1/server/dhcpd.c	2015-08-10 11:57:24.956325670 +0200
740675
@@ -58,6 +58,10 @@ gid_t set_gid = 0;
0ae0d1
 
0ae0d1
 #include "trace.h"
0ae0d1
 
3dbffb
+#ifdef HAVE_LIBSYSTEMD
0ae0d1
+#include <systemd/sd-daemon.h>
0ae0d1
+#endif
0ae0d1
+
0ae0d1
 #ifndef UNIT_TEST
0ae0d1
 static void usage(void);
0ae0d1
 #endif
740675
@@ -820,6 +824,13 @@ main(int argc, char **argv) {
0ae0d1
 
0ae0d1
 	TRACE(DHCPD_MAIN());
0ae0d1
 
3dbffb
+#ifdef HAVE_LIBSYSTEMD
0ae0d1
+        /* We are ready to process incomming packets. Let's notify systemd */
0ae0d1
+        sd_notifyf(0, "READY=1\n"
0ae0d1
+                   "STATUS=Dispatching packets...\n"
0ae0d1
+                   "MAINPID=%lu",
0ae0d1
+                   (unsigned long) getpid());
0ae0d1
+#endif
0ae0d1
 	/*
0ae0d1
 	 * Receive packets and dispatch them...
0ae0d1
 	 * dispatch() will never return.