SOURCES: libdhcp6client.pc (NEW), dhcpv6-gethwid.patch (NEW), dhcp...

arekm arekm at pld-linux.org
Tue Feb 20 20:24:13 CET 2007


Author: arekm                        Date: Tue Feb 20 19:24:13 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- new

---- Files affected:
SOURCES:
   libdhcp6client.pc (NONE -> 1.1)  (NEW), dhcpv6-gethwid.patch (NONE -> 1.1)  (NEW), dhcpv6-libdhcp6client.patch (NONE -> 1.1)  (NEW), dhcpv6-man.patch (NONE -> 1.1)  (NEW), dhcpv6-no-strlcat.patch (NONE -> 1.1)  (NEW), dhcpv6-redhat.patch (NONE -> 1.1)  (NEW), dhcpv6-relay.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/libdhcp6client.pc
diff -u /dev/null SOURCES/libdhcp6client.pc:1.1
--- /dev/null	Tue Feb 20 20:24:13 2007
+++ SOURCES/libdhcp6client.pc	Tue Feb 20 20:24:07 2007
@@ -0,0 +1,7 @@
+Name:		libdhcp6client
+Description:	The DHCPv6 IPv6 DHCP client library
+Version:	@DHCPV6_VERSION@
+Libs:		-ldhcp6client
+Libs.private:	-lresolv -lcrypto
+Cflags:		-I/usr/include/dhcp6client
+DHCPv6.Cflags=  -I/usr/include/dhcp6client/dhcpv6

================================================================
Index: SOURCES/dhcpv6-gethwid.patch
diff -u /dev/null SOURCES/dhcpv6-gethwid.patch:1.1
--- /dev/null	Tue Feb 20 20:24:13 2007
+++ SOURCES/dhcpv6-gethwid.patch	Tue Feb 20 20:24:07 2007
@@ -0,0 +1,20 @@
+--- dhcp-0.10/common.c.gethwid	2007-02-16 15:26:02.000000000 -0500
++++ dhcp-0.10/common.c	2007-02-16 15:26:02.000000000 -0500
+@@ -819,11 +819,15 @@
+ 		close(skfd);
+ 		return -1;
+ 	}
+-	close(skfd);
+ 
+ 	strcpy(if_hwaddr.ifr_name, ifname);
+-	if (ioctl(skfd, SIOCGIFHWADDR, &if_hwaddr) < 0)
++	if (ioctl(skfd, SIOCGIFHWADDR, &if_hwaddr) < 0) {
++		close(skfd);
+ 		return -1;
++	}
++
++	close(skfd);
++
+ 	/* only support Ethernet */
+ 	switch (if_hwaddr.ifr_hwaddr.sa_family) {
+ 	case ARPHRD_ETHER:

================================================================
Index: SOURCES/dhcpv6-libdhcp6client.patch
diff -u /dev/null SOURCES/dhcpv6-libdhcp6client.patch:1.1
--- /dev/null	Tue Feb 20 20:24:13 2007
+++ SOURCES/dhcpv6-libdhcp6client.patch	Tue Feb 20 20:24:07 2007
@@ -0,0 +1,1229 @@
+--- dhcp-0.10/client6_addr.c.libdhcp6client	2007-02-09 01:02:08.000000000 -0500
++++ dhcp-0.10/client6_addr.c	2007-02-09 01:02:08.000000000 -0500
+@@ -56,6 +56,10 @@
+ #include "timer.h"
+ #include "lease.h"
+ 
++#ifdef LIBDHCP
++#include "libdhcp_control.h"
++#endif
++
+ static int dhcp6_update_lease __P((struct dhcp6_addr *, struct dhcp6_lease *));
+ static int dhcp6_add_lease __P((struct dhcp6_addr *));
+ struct dhcp6_lease *dhcp6_find_lease __P((struct dhcp6_iaidaddr *, 
+@@ -231,14 +235,23 @@
+ 	if (sp->lease_addr.type == IAPD) {
+ 		dprintf(LOG_INFO, "request prefix is %s/%d", 
+ 			in6addr2str(&sp->lease_addr.addr, 0), sp->lease_addr.plen);
+-	} else if (client6_ifaddrconf(IFADDRCONF_ADD, addr) != 0) {
+-		dprintf(LOG_ERR, "%s" "adding address failed: %s",
+-		    FNAME, in6addr2str(&addr->addr, 0));
+-		if (sp->timer)
+-			dhcp6_remove_timer(sp->timer);
+-		free(sp);
+-		return (-1);
++#ifdef LIBDHCP
++	} else if (libdhcp_control && (libdhcp_control->capability & DHCP_CONFIGURE_ADDRESSES)) {
++#else
++	} else
++#endif
++		if (client6_ifaddrconf(IFADDRCONF_ADD, addr) != 0) {
++			dprintf(LOG_ERR, "%s" "adding address failed: %s",
++			        FNAME, in6addr2str(&addr->addr, 0));
++			if (sp->timer)
++				dhcp6_remove_timer(sp->timer);
++			free(sp);
++			return (-1);
++		}
++#ifdef LIBDHCP
+ 	}
++#endif
++
+ 	TAILQ_INSERT_TAIL(&client6_iaidaddr.lease_list, sp, link);
+ 	/* for infinite lifetime don't do any timer */
+ 	if (sp->lease_addr.validlifetime == DHCP6_DURATITION_INFINITE || 
+@@ -285,6 +298,9 @@
+ 	dprintf(LOG_DEBUG, "%s" "removing address %s", FNAME,
+ 		in6addr2str(&sp->lease_addr.addr, 0));
+ 	sp->state = INVALID;
++#ifdef LIBDHCP
++	if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE))
++#endif
+ 	if (write_lease(sp, client6_lease_file) != 0) {
+ 		dprintf(LOG_INFO, "%s" 
+ 			"failed to write removed lease address %s to lease file", 
+@@ -296,10 +312,13 @@
+ 		dprintf(LOG_INFO, "request prefix is %s/%d", 
+ 			in6addr2str(&sp->lease_addr.addr, 0), sp->lease_addr.plen);
+ 		/* XXX: remove from the update prefix list */
+-
+-	} else if (client6_ifaddrconf(IFADDRCONF_REMOVE, &sp->lease_addr) != 0) {
+-			dprintf(LOG_INFO, "%s" "removing address %s failed",
+-		    		FNAME, in6addr2str(&sp->lease_addr.addr, 0));
++	} else
++#ifdef LIBDHCP
++	if (libdhcp_control && (libdhcp_control->capability & DHCP_CONFIGURE_ADDRESSES))
++#endif
++	if (client6_ifaddrconf(IFADDRCONF_REMOVE, &sp->lease_addr) != 0) {
++		dprintf(LOG_INFO, "%s" "removing address %s failed",
++		        FNAME, in6addr2str(&sp->lease_addr.addr, 0));
+ 	}
+ 	/* remove expired timer for this lease. */
+ 	if (sp->timer)
+@@ -453,6 +472,9 @@
+ 	memcpy(&sp->lease_addr, addr, sizeof(sp->lease_addr));
+ 	sp->state = ACTIVE;
+ 	time(&sp->start_date);
++#ifdef LIBDHCP
++	if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE))
++#endif
+ 	if (write_lease(sp, client6_lease_file) != 0) {
+ 		dprintf(LOG_ERR, "%s" 
+ 			"failed to write an updated lease address %s to lease file", 
+--- dhcp-0.10/dhcp6c.c.libdhcp6client	2007-02-09 01:02:08.000000000 -0500
++++ dhcp-0.10/dhcp6c.c	2007-02-09 01:02:08.000000000 -0500
+@@ -73,6 +73,9 @@
+ #include "common.h"
+ #include "timer.h"
+ #include "lease.h"
++#ifdef LIBDHCP
++#include "libdhcp_control.h"
++#endif
+ 
+ static int debug = 0;
+ static u_long sig_flags = 0;
+@@ -136,7 +139,9 @@
+ 				   ssize_t, struct dhcp6_optinfo *));
+ static int client6_recvreply __P((struct dhcp6_if *, struct dhcp6 *,
+ 				  ssize_t, struct dhcp6_optinfo *));
++#ifndef LIBDHCP
+ static void client6_signal __P((int));
++#endif
+ static struct dhcp6_event *find_event_withid __P((struct dhcp6_if *,
+ 						  u_int32_t));
+ static struct dhcp6_timer *check_lease_file_timo __P((void *));
+@@ -155,20 +160,36 @@
+ #define DUID_FILE "/var/lib/dhcpv6/dhcp6c_duid"
+ 
+ static int pid;
++#ifdef LIBDHCP
++struct sockaddr_in6 sa6_allagent_storage;
++#endif
+ //static char cmdbuf[1024];
+ //static char oldlink[256];
+ char client6_lease_temp[256];
+ struct dhcp6_list request_list;
+ 
++#ifndef LIBDHCP
+ int
+-main(argc, argv)
++main(argc, argv, envp)
++#else
++#define exit return
++LIBDHCP_Control *libdhcp_control;
++__attribute__ ((visibility ("default")))
++int dhcpv6_client
++(libdhcp_ctl, argc, argv, envp)
++	LIBDHCP_Control *libdhcp_ctl;
++#endif
+ 	int argc;
+ 	char **argv;
++	char **envp;
+ {
+ 	int ch;
+ 	char *progname, *conffile = DHCP6C_CONF;
+ 	FILE *pidfp;
+ 	char *addr;
++#ifdef LIBDHCP
++	libdhcp_control = libdhcp_ctl;
++#endif
+ 
+ 	pid = getpid();
+ 	srandom(time(NULL) & pid);
+@@ -286,12 +307,18 @@
+ 	}
+ 	setloglevel(debug);
+ 
++#ifdef LIBDHCP
++	if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_PID_FILE))
++#endif
+ 	/* dump current PID */
+ 	if ((pidfp = fopen(DHCP6C_PIDFILE, "w")) != NULL) {
+ 		fprintf(pidfp, "%d\n", pid);
+ 		fclose(pidfp);
+ 	}
+ 
++#ifdef LIBDHCP
++	sa6_allagent = (const struct sockaddr_in6 *) &sa6_allagent_storage;
++#endif
+ 	ifinit(device);
+ 	setup_interface(device);
+ 
+@@ -303,7 +330,57 @@
+ 	client6_init(device);
+ 	client6_ifinit(device);
+ 	client6_mainloop();
+-	exit(0);
++#ifdef LIBDHCP
++	/* close all file descriptors */
++	close(nlsock);
++	nlsock = -1;
++	close(insock);
++	insock = -1;
++	close(outsock);
++	outsock = -1;
++	closelog();
++
++	/* release all memory */
++	sleep(1); /* keep valgrind happy :-) */
++	dhc6_free_all_pointers();
++
++	/* initialize globals */
++	optarg = 0L;
++	optind = 0;
++	opterr = 0;
++	optopt = 0;
++	memset(&client6_iaidaddr, '\0', sizeof(client6_iaidaddr));
++	dhcp6_if = NULL;
++	dadlist = NULL;
++	extern LIST_HEAD(, dhcp6_timer) timer_head;
++	memset(&timer_head, '\0', sizeof(timer_head));
++	memset(&request_list, '\0', sizeof(request_list));
++	memset(&sa6_allagent_storage, '\0', sizeof(sa6_allagent_storage));
++	sa6_allagent = (const struct sockaddr_in6 *) &sa6_allagent_storage;
++	memset(&client_duid, '\0', sizeof(client_duid));
++	memset(&iaidtab, '\0', sizeof(iaidtab));
++	client6_request_flag = 0;
++	memset(&leasename, '\0', sizeof(leasename));
++	debug = 0;
++	device = NULL;
++	num_device = 0;
++	sig_flags = 0;
++	extern struct host_conf *host_conflist;
++	host_conflist = 0;
++	client6_lease_file = server6_lease_file = sync_file = NULL;
++	cf_dns_list = NULL;
++	extern int cfdebug;
++	cfdebug = 0;
++	hash_anchors = 0;
++	configfilename = NULL;
++	debug_thresh = 0;
++	memset(&dnslist, '\0', sizeof(dnslist));
++	memset(&radvd_dhcpv6_file, '\0', sizeof(radvd_dhcpv6_file));
++	memset(&resolv_dhcpv6_file, '\0', sizeof(resolv_dhcpv6_file));
++	memset(&client6_lease_temp, '\0', sizeof(client6_lease_temp));
++	foreground = 0;
++#endif
++	return(0);
+ }
+ 
+ static void
+@@ -322,7 +399,9 @@
+ 	char *device;
+ {
+ 	struct addrinfo hints, *res;
++#ifndef LIBDHCP
+ 	static struct sockaddr_in6 sa6_allagent_storage;
++#endif
+ 	int error, on = 1;
+ 	struct dhcp6_if *ifp;
+ 	int ifidx;
+@@ -335,19 +414,19 @@
+ 	ifidx = if_nametoindex(device);
+ 	if (ifidx == 0) {
+ 		dprintf(LOG_ERR, "if_nametoindex(%s)", device);
+-		exit(1);
++		return;
+ 	}
+ 
+ 	/* get our DUID */
+ 	if (get_duid(DUID_FILE, device, &client_duid)) {
+ 		dprintf(LOG_ERR, "%s" "failed to get a DUID", FNAME);
+-		exit(1);
++		return;
+ 	}
+ 	if (get_linklocal(device, &lladdr) < 0) {
+-		exit(1);
++		return;
+ 	}
+ 	if (inet_ntop(AF_INET6, &lladdr, linklocal, sizeof(linklocal)) < 0) {
+-		exit(1);
++		return;
+ 	}
+ 	dprintf(LOG_DEBUG, "link local addr is %s", linklocal);
+ 	
+@@ -360,12 +439,12 @@
+ 	if (error) {
+ 		dprintf(LOG_ERR, "%s" "getaddrinfo: %s",
+ 			FNAME, strerror(error));
+-		exit(1);
++		return;
+ 	}
+ 	insock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ 	if (insock < 0) {
+ 		dprintf(LOG_ERR, "%s" "socket(inbound)", FNAME);
+-		exit(1);
++		return;
+ 	}
+ #ifdef IPV6_RECVPKTINFO
+ 	if (setsockopt(insock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on,
+@@ -373,7 +452,7 @@
+ 		dprintf(LOG_ERR, "%s"
+ 			"setsockopt(inbound, IPV6_RECVPKTINFO): %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
+ #else
+ 	if (setsockopt(insock, IPPROTO_IPV6, IPV6_PKTINFO, &on,
+@@ -381,7 +460,7 @@
+ 		dprintf(LOG_ERR, "%s"
+ 			"setsockopt(inbound, IPV6_PKTINFO): %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
+ #endif
+ 	((struct sockaddr_in6 *)(res->ai_addr))->sin6_scope_id = ifidx;
+@@ -410,7 +489,7 @@
+ 
+ 	if (bound < 0) {
+ 		dprintf(LOG_ERR, "%s" "bind(inbound): %s", FNAME, strerror(-bound));
+-		exit(bound);
++		return;
+ 	}
+ 
+ 	freeaddrinfo(res);
+@@ -420,26 +499,26 @@
+ 	if (error) {
+ 		dprintf(LOG_ERR, "%s" "getaddrinfo: %s",
+ 			FNAME, gai_strerror(error));
+-		exit(1);
++		return;
+ 	}
+ 	outsock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ 	if (outsock < 0) {
+ 		dprintf(LOG_ERR, "%s" "socket(outbound): %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
+ 	if (setsockopt(outsock, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+ 			&ifidx, sizeof(ifidx)) < 0) {
+ 		dprintf(LOG_ERR, "%s"
+ 			"setsockopt(outbound, IPV6_MULTICAST_IF): %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
+ 	((struct sockaddr_in6 *)(res->ai_addr))->sin6_scope_id = ifidx;
+ 	if (bind(outsock, res->ai_addr, res->ai_addrlen) < 0) {
+ 		dprintf(LOG_ERR, "%s" "bind(outbound): %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
+ 	freeaddrinfo(res);
+ 	memset(&hints, 0, sizeof(hints));
+@@ -450,7 +529,7 @@
+ 	if (error) {
+ 		dprintf(LOG_ERR, "%s" "getaddrinfo: %s",
+ 			FNAME, gai_strerror(error));
+-		exit(1);
++		return;
+ 	}
+ 	memcpy(&sa6_allagent_storage, res->ai_addr, res->ai_addrlen);
+ 	sa6_allagent = (const struct sockaddr_in6 *)&sa6_allagent_storage;
+@@ -461,25 +540,27 @@
+ 	if ((ifp = find_ifconfbyname(device)) == NULL) {
+ 		dprintf(LOG_ERR, "%s" "interface %s not configured",
+ 			FNAME, device);
+-		exit(1);
++		return;
+ 	}
+ 	ifp->outsock = outsock;
+ 
++#ifndef LIBDHCP
+ 	if (signal(SIGHUP, client6_signal) == SIG_ERR) {
+ 		dprintf(LOG_WARNING, "%s" "failed to set signal: %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
+ 	if (signal(SIGTERM|SIGKILL, client6_signal) == SIG_ERR) {
+ 		dprintf(LOG_WARNING, "%s" "failed to set signal: %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
+ 	if (signal(SIGINT, client6_signal) == SIG_ERR) {
+ 		dprintf(LOG_WARNING, "%s" "failed to set signal: %s",
+ 			FNAME, strerror(errno));
+-		exit(1);
++		return;
+ 	}
++#endif
+ }
+ 
+ static void
+@@ -493,13 +574,13 @@
+ 	/* get iaid for each interface */
+ 	if (num_device == 0) {
+ 		if ((num_device = create_iaid(&iaidtab[0], num_device)) < 0)
+-			exit(1);
++			return;
+ 		ifp->iaidinfo.iaid = get_iaid(ifp->ifname, &iaidtab[0], num_device);
+ 		if (ifp->iaidinfo.iaid == 0) {
+ 			dprintf(LOG_DEBUG, "%s" 
+ 				"interface %s iaid failed to be created", 
+ 				FNAME, ifp->ifname);
+-			exit(1);
++			return;
+ 		}
+ 		dprintf(LOG_DEBUG, "%s" "interface %s iaid is %u", 
+ 			FNAME, ifp->ifname, ifp->iaidinfo.iaid);
+@@ -508,6 +589,9 @@
+ 	memcpy(&client6_iaidaddr.client6_info.iaidinfo, &ifp->iaidinfo, 
+ 			sizeof(client6_iaidaddr.client6_info.iaidinfo));
+ 	duidcpy(&client6_iaidaddr.client6_info.clientid, &client_duid);
++#ifdef LIBDHCP
++	if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE)) {
++#endif
+ 	/* parse the lease file */
+ 	strcpy(leasename, PATH_CLIENT6_LEASE);
+ 	sprintf(iaidstr, "%u", ifp->iaidinfo.iaid);
+@@ -515,14 +599,17 @@
+ 	if ((client6_lease_file = 
+ 		init_leases(leasename)) == NULL) {
+ 			dprintf(LOG_ERR, "%s" "failed to parse lease file", FNAME);
+-		exit(1);
++		return;
+ 	}
+ 	strcpy(client6_lease_temp, leasename);
+ 	strcat(client6_lease_temp, "XXXXXX");
+ 	client6_lease_file = 
+ 		sync_leases(client6_lease_file, leasename, client6_lease_temp);
+ 	if (client6_lease_file == NULL)
+-		exit(1);
++		return;
++#ifdef LIBDHCP
++	}
++#endif
+ 	if (!TAILQ_EMPTY(&client6_iaidaddr.lease_list)) {
+ //		struct dhcp6_lease *cl;
+ 		struct dhcp6_listval *lv;
+@@ -531,7 +618,7 @@
+ 			client6_request_flag |= CLIENT6_CONFIRM_ADDR;
+ 		if (TAILQ_EMPTY(&request_list)) {
+ 			if (create_request_list(1) < 0) 
+-				exit(1);
++				return;
+ 		} else if (client6_request_flag & CLIENT6_RELEASE_ADDR) {
+ 			for (lv = TAILQ_FIRST(&request_list); lv; 
+ 					lv = TAILQ_NEXT(lv, link)) {
+@@ -540,13 +627,13 @@
+ 					dprintf(LOG_INFO, "this address %s is not"
+ 						" leased by this client", 
+ 					    in6addr2str(&lv->val_dhcp6addr.addr,0));
+-					exit(0);
++					return;
+ 				}
+ 			}
+ 		}	
+ 	} else if (client6_request_flag & CLIENT6_RELEASE_ADDR) {
+ 		dprintf(LOG_INFO, "no ipv6 addresses are leased by client");
+-		exit(0);
++		return;
+ 	}
+ 	ifp->link_flag |= IFF_RUNNING;
+ 
+@@ -557,11 +644,11 @@
+ 	if ((ifp->link_timer =
+ 	    dhcp6_add_timer(check_link_timo, ifp)) < 0) {
+ 		dprintf(LOG_ERR, "%s" "failed to create a timer", FNAME);
+-		exit(1);
++		return;
+ 	}
+ 	if ((ifp->sync_timer = dhcp6_add_timer(check_lease_file_timo, ifp)) < 0) {
+ 		dprintf(LOG_ERR, "%s" "failed to create a timer", FNAME);
+-		exit(1);
++		return;
+ 	}
+ 	/* DAD timer set up after getting the address */
+ 	ifp->dad_timer = NULL;
+@@ -569,7 +656,7 @@
+ 	if ((ev = dhcp6_create_event(ifp, DHCP6S_INIT)) == NULL) {
+ 		dprintf(LOG_ERR, "%s" "failed to create an event",
+ 			FNAME);
+-		exit(1);
++		return;
+ 	}
+ 	ifp->servers = NULL;
+ 	ev->ifp->current_server = NULL;
+@@ -577,7 +664,7 @@
+ 	if ((ev->timer = dhcp6_add_timer(client6_timo, ev)) == NULL) {
+ 		dprintf(LOG_ERR, "%s" "failed to add a timer for %s",
+ 			FNAME, ifp->ifname);
+-		exit(1);
++		return;
+ 	}
+ 	dhcp6_reset_timer(ev);
+ }
+@@ -594,6 +681,9 @@
+ 	else {
+ 		for (sp = TAILQ_FIRST(&client6_iaidaddr.lease_list); sp; sp = sp_next) { 
+ 			sp_next = TAILQ_NEXT(sp, link);
++#ifdef LIBDHCP
++	if (libdhcp_control && (libdhcp_control->capability & DHCP_CONFIGURE_ADDRESSES))
++#endif
+ 			if (client6_ifaddrconf(IFADDRCONF_REMOVE, &sp->lease_addr) != 0) 
+ 				dprintf(LOG_INFO, "%s" "deconfiging address %s failed",
+ 					FNAME, in6addr2str(&sp->lease_addr.addr, 0));
+@@ -605,6 +695,9 @@
+ 		ev_next = TAILQ_NEXT(ev, link);
+ 		dhcp6_remove_event(ev);
+ 	}
++#ifdef LIBDHCP
++	if (libdhcp_control && (libdhcp_control->capability & DHCP_CONFIGURE_RADVD))
++#endif
+ 	/* XXX: check the last dhcpv6 client daemon to restore the original file */
+ 	{
+ 		/* restore /etc/radv.conf.bak back to /etc/radvd.conf */
+@@ -627,7 +720,7 @@
+ 		dprintf(LOG_INFO, FNAME "exiting");
+ 		free_resources(dhcp6_if);
+ 		unlink(DHCP6C_PIDFILE);
+-		exit(0);
++		return;
+ 	}
+ 	if ((sig_flags & SIGF_HUP)) {
+ 		dprintf(LOG_INFO, FNAME "restarting");
+@@ -636,7 +729,7 @@
+ 	}
+ 	if ((sig_flags & SIGF_CLEAN)) {
+ 		free_resources(dhcp6_if);
+-		exit(0);
++		return;
+ 	}
+ 	sig_flags = 0;
+ }
+@@ -648,11 +741,39 @@
+ 	int ret;
+ 	fd_set r;
+ 
++#ifdef LIBDHCP
++	struct timeval fb; /* fallback timeout */
++
++	if (libdhcp_control) {
++		if (libdhcp_control->timeout)
++			libdhcp_control->now = time(0);
++		else
++			libdhcp_control->now = 0;
++	}
++#endif
++
+ 	while(1) {
+ 		if (sig_flags)
+ 			process_signals();
+ 		w = dhcp6_check_timer();
+ 
++#ifdef LIBDHCP
++		if (libdhcp_control && libdhcp_control->timeout) {
++			time_t now = time(0);
++			double a = (double) w->tv_sec + now;
++			double b = (double) w->tv_usec / 1000000.0;
++			double c = (double) libdhcp_control->now;
++			double d = (double) libdhcp_control->timeout;
++			if ((w == NULL) || ((a + b) >= (c + d))) {
++				w = &fb;
++				fb.tv_sec = 0;
++				fb.tv_usec = 0;
++				if (now < (libdhcp_control->now + libdhcp_control->timeout))
++					fb.tv_sec = (libdhcp_control->now + libdhcp_control->timeout) - now;
++			}
++		}
++#endif
++
+ 		FD_ZERO(&r);
+ 		FD_SET(insock, &r);
+ 
+@@ -662,7 +783,7 @@
+ 			if (errno != EINTR) {
+ 				dprintf(LOG_ERR, "%s" "select: %s",
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list