8173a68
diff -up dhcp-4.3.4/configure.ac.sd_notify dhcp-4.3.4/configure.ac
8173a68
--- dhcp-4.3.4/configure.ac.sd_notify	2016-04-29 13:08:52.813287060 +0200
8173a68
+++ dhcp-4.3.4/configure.ac	2016-04-29 13:08:52.872287075 +0200
8173a68
@@ -832,6 +832,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"
8173a68
diff -up dhcp-4.3.4/relay/dhcrelay.c.sd_notify dhcp-4.3.4/relay/dhcrelay.c
8173a68
--- dhcp-4.3.4/relay/dhcrelay.c.sd_notify	2016-04-29 13:08:52.814287061 +0200
8173a68
+++ dhcp-4.3.4/relay/dhcrelay.c	2016-04-29 13:08:52.872287075 +0200
8173a68
@@ -37,6 +37,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];
8173a68
@@ -709,6 +713,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
 
8173a68
diff -up dhcp-4.3.4/server/dhcpd.c.sd_notify dhcp-4.3.4/server/dhcpd.c
8173a68
--- dhcp-4.3.4/server/dhcpd.c.sd_notify	2016-04-29 13:08:52.873287075 +0200
8173a68
+++ dhcp-4.3.4/server/dhcpd.c	2016-04-29 13:12:00.655333096 +0200
8173a68
@@ -57,6 +57,10 @@ uid_t set_uid = 0;
8173a68
 gid_t set_gid = 0;
8173a68
 #endif /* PARANOIA */
0ae0d11
 
3dbffba
+#ifdef HAVE_LIBSYSTEMD
0ae0d11
+#include <systemd/sd-daemon.h>
0ae0d11
+#endif
0ae0d11
+
8173a68
 struct iaddr server_identifier;
8173a68
 int server_identifier_matched;
0ae0d11
 
8173a68
@@ -931,6 +935,14 @@ main(int argc, char **argv) {
8173a68
 	/* Log that we are about to start working */
8173a68
 	log_info("Server starting service.");
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
8173a68
+
0ae0d11
 	/*
0ae0d11
 	 * Receive packets and dispatch them...
0ae0d11
 	 * dispatch() will never return.