diff options
author | Ethan Galstad <egalstad@users.sourceforge.net> | 2003-02-16 02:46:40 (GMT) |
---|---|---|
committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2003-02-16 02:46:40 (GMT) |
commit | 33139519aaac2a964975c6da5c4efa3fde6f8585 (patch) | |
tree | 98a36b4537ec07447d536331e3f4ad194a851a82 /contrib | |
parent | 983b1edec4399c7bb473785567bbeb7d338d705b (diff) | |
download | monitoring-plugins-33139519aaac2a964975c6da5c4efa3fde6f8585.tar.gz |
Interface patch byor Clemens Resen
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@326 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/check_dhcp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/check_dhcp.c b/contrib/check_dhcp.c index 24b82f9..2aea579 100644 --- a/contrib/check_dhcp.c +++ b/contrib/check_dhcp.c | |||
@@ -515,6 +515,7 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st | |||
515 | /* creates a socket for DHCP communication */ | 515 | /* creates a socket for DHCP communication */ |
516 | int create_dhcp_socket(void){ | 516 | int create_dhcp_socket(void){ |
517 | struct sockaddr_in myname; | 517 | struct sockaddr_in myname; |
518 | struct ifreq interface; | ||
518 | int sock; | 519 | int sock; |
519 | int flag=1; | 520 | int flag=1; |
520 | 521 | ||
@@ -549,6 +550,13 @@ int create_dhcp_socket(void){ | |||
549 | exit(STATE_UNKNOWN); | 550 | exit(STATE_UNKNOWN); |
550 | } | 551 | } |
551 | 552 | ||
553 | /* bind socket to interface */ | ||
554 | strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ); | ||
555 | if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){ | ||
556 | printf("Error: Could not bind socket to interface %s. Check your privileges...\n",network_interface_name); | ||
557 | exit(STATE_UNKNOWN); | ||
558 | } | ||
559 | |||
552 | /* bind the socket */ | 560 | /* bind the socket */ |
553 | if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){ | 561 | if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){ |
554 | printf("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n",DHCP_CLIENT_PORT); | 562 | printf("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n",DHCP_CLIENT_PORT); |