dhcp dispatcher event patch.



Hello,

I've created a small patch that was discussed in this bugrepport, https://bugzilla.gnome.org/show_bug.cgi?id=563654. It's a tiny patch that adds a dispatcher event on the dhcp_renew state and updates the manpage accordingly.

This is useful if you want to for e.g. use nsupdate to dynamicly update dns-entries. You probably want to do that everytime a lease is renewed. What you also could do (what i used to) is to use a cron-job that runs with tighter interval than the dns-server uses to hold entries, however that method is quite messy and not preferred.

I'm no programmer so go easy on me if I missunderstood anything in the coding part. (one line) :)

/Patrik Martinsson,
Sweden.



--- a/NetworkManager/src/nm-device.c	2010-08-18 15:29:33.000000000 +0200
+++ b/NetworkManager/src/nm-device.c	2010-08-18 15:26:29.000000000 +0200
@@ -1398,10 +1398,16 @@
 	}
 
 	switch (state) {
+		/* Make dispatcher-calls for the renew dhcp-states. 
+		 * This is needed if you for e.g. want to script dynamic dns 
+		 * updates on lease renewals.
+		 */
 	case DHC_BOUND4:     /* lease obtained */
-	case DHC_BOUND6:
+	case DHC_BOUND6:     /* lease obtained */
 	case DHC_RENEW4:     /* lease renewed */
+		nm_utils_call_dispatcher ("dhcp4_renew", NULL, device, NULL);
 	case DHC_RENEW6:     /* lease renewed */
+		nm_utils_call_dispatcher ("dhcp6_renew", NULL, device, NULL);
 	case DHC_REBOOT:     /* have valid lease, but now obtained a different one */
 	case DHC_REBIND4:    /* new, different lease */
 	case DHC_REBIND6:    /* new, different lease */
--- a/NetworkManager/man/NetworkManager.8.in	2010-08-18 15:29:33.000000000 +0200
+++ b/NetworkManager/man/NetworkManager.8.in	2010-08-18 15:52:03.000000000 +0200
@@ -50,6 +50,9 @@
 .I "vpn\-down"
 A VPN connection has been deactivated.
 .TP
+.I "dhcp[4|6]_renew"
+The dhcp lease for IPv4/6 has been renewed (This could be useful for e.g. if you want to update dynamic dns entries at lease renewals).
+.TP
 .I "hostname"
 The system hostname has been updated.  Use gethostname(2) to retrieve it.
 .SH OPTIONS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]