[Nagiosplug-checkins] CVS: nagiosplug/contrib check_dhcp.c,1.3,1.4

Ethan Galstad egalstad at users.sourceforge.net
Sat Feb 15 18:47:04 CET 2003


Update of /cvsroot/nagiosplug/nagiosplug/contrib
In directory sc8-pr-cvs1:/tmp/cvs-serv20509

Modified Files:
	check_dhcp.c 
Log Message:
Interface patch byor Clemens Resen

Index: check_dhcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/contrib/check_dhcp.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** check_dhcp.c	13 Jan 2003 12:21:51 -0000	1.3
--- check_dhcp.c	16 Feb 2003 02:46:40 -0000	1.4
***************
*** 516,519 ****
--- 516,520 ----
  int create_dhcp_socket(void){
          struct sockaddr_in myname;
+ 	struct ifreq interface;
          int sock;
          int flag=1;
***************
*** 547,550 ****
--- 548,558 ----
          if(setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
  		printf("Error: Could not set broadcast option on DHCP socket!\n");
+ 		exit(STATE_UNKNOWN);
+ 	        }
+ 
+ 	/* bind socket to interface */
+ 	strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ);
+ 	if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){
+ 		printf("Error: Could not bind socket to interface %s.  Check your privileges...\n",network_interface_name);
  		exit(STATE_UNKNOWN);
  	        }





More information about the Commits mailing list