0ae0d1
diff -up dhcp-4.3.0/configure.ac.sd-daemon dhcp-4.3.0/configure.ac
0ae0d1
--- dhcp-4.3.0/configure.ac.sd-daemon	2014-03-18 15:17:11.000000000 +0100
0ae0d1
+++ dhcp-4.3.0/configure.ac	2014-03-18 15:35:47.982182345 +0100
0ae0d1
@@ -677,6 +677,17 @@ if test x$ldap = xyes || test x$ldapcryp
0ae0d1
     fi
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"
0ae0d1
diff -up dhcp-4.3.0/relay/dhcrelay.c.sd-daemon dhcp-4.3.0/relay/dhcrelay.c
0ae0d1
--- dhcp-4.3.0/relay/dhcrelay.c.sd-daemon	2014-03-18 15:17:11.000000000 +0100
0ae0d1
+++ dhcp-4.3.0/relay/dhcrelay.c	2014-03-18 15:35:42.063264999 +0100
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];
0ae0d1
@@ -624,6 +628,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
 
0ae0d1
diff -up dhcp-4.3.0/server/dhcpd.c.sd-daemon dhcp-4.3.0/server/dhcpd.c
0ae0d1
--- dhcp-4.3.0/server/dhcpd.c.sd-daemon	2014-03-18 15:17:11.000000000 +0100
0ae0d1
+++ dhcp-4.3.0/server/dhcpd.c	2014-03-18 15:34:59.207863458 +0100
0ae0d1
@@ -54,6 +54,10 @@ static const char url [] =
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
0ae0d1
@@ -792,6 +796,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.