summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--plugins-root/check_dhcp.c38
2 files changed, 20 insertions, 19 deletions
diff --git a/NEWS b/NEWS
index 2d19664..7170b19 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ This file documents the major additions and syntax changes between releases.
13 to check DHCP servers on remote networks 13 to check DHCP servers on remote networks
14 New check_dhcp -m/--mac option which allows for specifying the MAC 14 New check_dhcp -m/--mac option which allows for specifying the MAC
15 address to use in the DHCP request 15 address to use in the DHCP request
16 The check_dhcp -r and -s options now accept host names, too
16 17
171.4.9 4th June 2006 181.4.9 4th June 2006
18 Inclusion of contrib/check_cluster2 as check_cluster with some improvements 19 Inclusion of contrib/check_cluster2 as check_cluster with some improvements
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index a0f150f..c6e5af8 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -243,6 +243,7 @@ int validate_arguments(void);
243void print_usage(void); 243void print_usage(void);
244void print_help(void); 244void print_help(void);
245 245
246void resolve_host(const char *in,struct in_addr *out);
246unsigned char *mac_aton(const char *); 247unsigned char *mac_aton(const char *);
247void print_hardware_address(const unsigned char *); 248void print_hardware_address(const unsigned char *);
248int get_hardware_address(int,char *); 249int get_hardware_address(int,char *);
@@ -1089,7 +1090,6 @@ int process_arguments(int argc, char **argv){
1089int call_getopt(int argc, char **argv){ 1090int call_getopt(int argc, char **argv){
1090 int c=0; 1091 int c=0;
1091 int i=0; 1092 int i=0;
1092 struct in_addr ipaddress;
1093 1093
1094 int option_index = 0; 1094 int option_index = 0;
1095 static struct option long_options[] = 1095 static struct option long_options[] =
@@ -1128,27 +1128,13 @@ int call_getopt(int argc, char **argv){
1128 switch(c){ 1128 switch(c){
1129 1129
1130 case 's': /* DHCP server address */ 1130 case 's': /* DHCP server address */
1131 if(inet_aton(optarg,&ipaddress)){ 1131 resolve_host(optarg,&dhcp_ip);
1132 add_requested_server(ipaddress); 1132 add_requested_server(dhcp_ip);
1133 inet_aton(optarg, &dhcp_ip);
1134 if (verbose)
1135 printf("querying %s\n",inet_ntoa(dhcp_ip));
1136 }
1137 /*
1138 else
1139 usage("Invalid server IP address\n");
1140 */
1141 break; 1133 break;
1142 1134
1143 case 'r': /* address we are requested from DHCP servers */ 1135 case 'r': /* address we are requested from DHCP servers */
1144 if(inet_aton(optarg,&ipaddress)){ 1136 resolve_host(optarg,&requested_address);
1145 requested_address=ipaddress; 1137 request_specific_address=TRUE;
1146 request_specific_address=TRUE;
1147 }
1148 /*
1149 else
1150 usage("Invalid requested IP address\n");
1151 */
1152 break; 1138 break;
1153 1139
1154 case 't': /* timeout */ 1140 case 't': /* timeout */
@@ -1352,6 +1338,20 @@ long mac_addr_dlpi( const char *dev, int unit, u_char *addr){
1352#endif 1338#endif
1353 1339
1354 1340
1341/* resolve host name or die (TODO: move this to netutils.c!) */
1342void resolve_host(const char *in,struct in_addr *out){
1343 struct addrinfo hints, *ai;
1344
1345 memset(&hints,0,sizeof(hints));
1346 hints.ai_family=PF_INET;
1347 if (getaddrinfo(in,NULL,&hints,&ai) != 0)
1348 usage_va(_("Invalid hostname/address - %s"),optarg);
1349
1350 memcpy(out,&((struct sockaddr_in *)ai->ai_addr)->sin_addr,sizeof(*out));
1351 freeaddrinfo(ai);
1352 }
1353
1354
1355/* parse MAC address string, return 6 bytes (unterminated) or NULL */ 1355/* parse MAC address string, return 6 bytes (unterminated) or NULL */
1356unsigned char *mac_aton(const char *string){ 1356unsigned char *mac_aton(const char *string){
1357 static unsigned char result[6]; 1357 static unsigned char result[6];