Only in vrrpd-chris: ipaddr.o
Only in vrrpd-chris: libnetlink.o
Binary files vrrpd/vrrpd and vrrpd-chris/vrrpd differ
diff -ru2 vrrpd/vrrpd.c vrrpd-chris/vrrpd.c
--- vrrpd/vrrpd.c	Thu Oct  5 03:11:39 2000
+++ vrrpd-chris/vrrpd.c	Thu Jan 16 13:27:48 2003
@@ -169,5 +169,5 @@
 	uint32_t	addr	= 0;
 	if (fd < 0) 	return (-1);
-	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)-1);
 	if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) == 0) {
 		struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
@@ -189,5 +189,5 @@
 	int		ifindex = -1;
 	if (fd < 0) 	return (-1);
-	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)-1);
 	if (ioctl(fd, SIOCGIFINDEX, (char *)&ifr) == 0)
 		ifindex = ifr.ifr_ifindex;
@@ -207,5 +207,5 @@
 	int		ret;
 	if (fd < 0) 	return (-1);
-	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)-1);
 	memcpy( ifr.ifr_hwaddr.sa_data, addr, addrlen );
 	ifr.ifr_hwaddr.sa_family = AF_UNSPEC;
@@ -232,5 +232,5 @@
 	unsigned long	flags;
 	if (fd < 0) 	return (-1);
-	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)-1);
 	/* get the flags */
 	ret = ioctl(fd, SIOCGIFFLAGS, (char *)&ifr);
@@ -268,5 +268,5 @@
 	int		ret;
 	if (fd < 0) 	return (-1);
-	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)-1);
 	ret = ioctl(fd, SIOCGIFHWADDR, (char *)&ifr);
 	memcpy( addr, ifr.ifr_hwaddr.sa_data, addrlen );
@@ -520,10 +520,10 @@
 	}
 	/* build the address */
-	memset( &from, 0 , sizeof(from));
-	strcpy( from.sa_data, vsrv->vif.ifname );
+	memset(&from, 0 , sizeof(from));
+	strncpy(from.sa_data, vsrv->vif.ifname, sizeof(from)-1);
 	/* send the data */
-	len = sendto( fd, buffer, buflen, 0, &from, sizeof(from) );
+	len = sendto(fd, buffer, buflen, 0, &from, sizeof(from));
 //printf("len=%d\n",len);
-	close( fd );
+	close(fd);
 	return len;
 }
@@ -565,20 +565,22 @@
 {
 	fprintf( stderr, "vrrpd version %s\n", VRRPD_VERSION );
-	fprintf( stderr, "Usage: vrrpd -i ifname -v vrid [-f piddir] [-s] [-a auth] [-p prio] [-nh] ipaddr\n" );
-	fprintf( stderr, "  -h       : display this short inlined help\n" );
-	fprintf( stderr, "  -n       : Dont handle the virtual mac address\n" );
-	fprintf( stderr, "  -i ifname: the interface name to run on\n" );
-	fprintf( stderr, "  -v vrid  : the id of the virtual server [1-255]\n" );
-	fprintf( stderr, "  -s       : Switch the preemption mode (%s by default)\n"
+	fprintf( stderr, "Usage: vrrpd -i ifname -v vrid [OPTION]... ipaddr\n" );
+	fprintf( stderr, "\n" );
+	fprintf( stderr, "  -h         display this short inlined help\n" );
+	fprintf( stderr, "  -n         don't handle the virtual mac address\n" );
+	fprintf( stderr, "  -i ifname  the interface name to run on\n" );
+	fprintf( stderr, "  -v vrid    the id of the virtual server [1-255]\n" );
+	fprintf( stderr, "  -s         switch the preemption mode (%s by default)\n"
 				, VRRP_PREEMPT_DFL? "Enabled" : "Disabled" );
-	fprintf( stderr, "  -a auth  : (not yet implemented) set the authentification type\n" );
+	fprintf( stderr, "  -a auth    (not yet implemented) set the authentification type\n" );
 	fprintf( stderr, "             auth=(none|pass/hexkey|ah/hexkey) hexkey=0x[0-9a-fA-F]+\n");
-	fprintf( stderr, "  -p prio  : Set the priority of this host in the virtual server (dfl: %d)\n"
+	fprintf( stderr, "  -p prio    set the priority of this host in the virtual server (dfl: %d)\n"
 							, VRRP_PRIO_DFL );
-	fprintf( stderr, "  -f piddir: specify the directory where the pid file is stored (dfl: %s)\n"
+	fprintf( stderr, "  -f piddir  specify the directory where the pid file is stored (dfl: %s)\n"
 							, VRRP_PIDDIR_DFL );
-	fprintf( stderr, "  -d delay : Set the advertisement interval (in sec) (dfl: %d)\n"
+	fprintf( stderr, "  -d delay   set the advertisement interval (in sec) (dfl: %d)\n"
 							, VRRP_ADVER_DFL );
-	fprintf( stderr, "  ipaddr   : the ip address(es) of the virtual server\n" );
+	fprintf( stderr, "  -D         enable daemon mode, run in background\n" );
+	fprintf( stderr, "  ipaddr     the ip address(es) of the virtual server\n" );
 }
 
@@ -634,5 +636,5 @@
 	int	c;
 	while( 1 ){
-		c = getopt( argc, argv, "f:si:v:a:p:d:hn" );
+		c = getopt( argc, argv, "f:si:v:a:p:d:hnD" );
 		/* if the parsing is completed, exit */
 		if( c == EOF )	break;
@@ -644,4 +646,7 @@
 			vsrv->preempt	= !vsrv->preempt;
 			break;
+		case 'D':
+			vsrv->daemon	= 1;
+			break;
 		case 'f':
 			snprintf( PidDir, sizeof(PidDir), "%s", optarg );
@@ -1116,4 +1121,10 @@
 	pidfile_write( vsrv );
 
+	if( vsrv->daemon ){
+		daemon(0, 0);
+		/* parent is dead, child has a new pid, rewrite pid file */
+		pidfile_write( vsrv );
+	}
+
 	/* main loop */
 	while( 1 ){
diff -ru2 vrrpd/vrrpd.h vrrpd-chris/vrrpd.h
--- vrrpd/vrrpd.h	Thu Oct  5 02:59:46 2000
+++ vrrpd-chris/vrrpd.h	Thu Jan 16 13:09:25 2003
@@ -78,4 +78,5 @@
 #endif
 	int	preempt;	/* true if a higher prio preempt a lower one */
+	int 	daemon;		/* true if we should go into the background */
 
 	int	state;		/* internal state (init/backup/master) */
Only in vrrpd-chris: vrrpd.o
