summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ee33124)
raw | patch | inline | side by side (parent: ee33124)
author | Holger Weiss <hweiss@users.sourceforge.net> | |
Thu, 26 Jul 2007 17:32:37 +0000 (17:32 +0000) | ||
committer | Holger Weiss <hweiss@users.sourceforge.net> | |
Thu, 26 Jul 2007 17:32:37 +0000 (17:32 +0000) |
This doesn't quite fit the option names and so far I haven't changed the
"--help" output which currently only talks about IP addresses. However,
I don't see why resolving host names should not be supported.
Also note that for the moment, I added a quick'n'dirty resolve_host()
function which should really go into netutils.c. I just wanted to think
about its interface a bit more before providing such a function globally.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1766 f882894a-f735-0410-b71e-b25c423dba1c
"--help" output which currently only talks about IP addresses. However,
I don't see why resolving host names should not be supported.
Also note that for the moment, I added a quick'n'dirty resolve_host()
function which should really go into netutils.c. I just wanted to think
about its interface a bit more before providing such a function globally.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1766 f882894a-f735-0410-b71e-b25c423dba1c
NEWS | patch | blob | history | |
plugins-root/check_dhcp.c | patch | blob | history |
index 2d19664bf83c843b7d5321932581b4a6b5d47b0b..7170b19c6353d629feb0d6ec9f41c5ee344c9128 100644 (file)
--- a/NEWS
+++ b/NEWS
to check DHCP servers on remote networks
New check_dhcp -m/--mac option which allows for specifying the MAC
address to use in the DHCP request
+ The check_dhcp -r and -s options now accept host names, too
1.4.9 4th June 2006
Inclusion of contrib/check_cluster2 as check_cluster with some improvements
index a0f150fbf281b8809eff8adc5f060ce80531a27c..c6e5af8ab7aed93828f49933a1716ca4c638b73e 100644 (file)
void print_usage(void);
void print_help(void);
+void resolve_host(const char *in,struct in_addr *out);
unsigned char *mac_aton(const char *);
void print_hardware_address(const unsigned char *);
int get_hardware_address(int,char *);
int call_getopt(int argc, char **argv){
int c=0;
int i=0;
- struct in_addr ipaddress;
int option_index = 0;
static struct option long_options[] =
switch(c){
case 's': /* DHCP server address */
- if(inet_aton(optarg,&ipaddress)){
- add_requested_server(ipaddress);
- inet_aton(optarg, &dhcp_ip);
- if (verbose)
- printf("querying %s\n",inet_ntoa(dhcp_ip));
- }
- /*
- else
- usage("Invalid server IP address\n");
- */
+ resolve_host(optarg,&dhcp_ip);
+ add_requested_server(dhcp_ip);
break;
case 'r': /* address we are requested from DHCP servers */
- if(inet_aton(optarg,&ipaddress)){
- requested_address=ipaddress;
- request_specific_address=TRUE;
- }
- /*
- else
- usage("Invalid requested IP address\n");
- */
+ resolve_host(optarg,&requested_address);
+ request_specific_address=TRUE;
break;
case 't': /* timeout */
#endif
+/* resolve host name or die (TODO: move this to netutils.c!) */
+void resolve_host(const char *in,struct in_addr *out){
+ struct addrinfo hints, *ai;
+
+ memset(&hints,0,sizeof(hints));
+ hints.ai_family=PF_INET;
+ if (getaddrinfo(in,NULL,&hints,&ai) != 0)
+ usage_va(_("Invalid hostname/address - %s"),optarg);
+
+ memcpy(out,&((struct sockaddr_in *)ai->ai_addr)->sin_addr,sizeof(*out));
+ freeaddrinfo(ai);
+ }
+
+
/* parse MAC address string, return 6 bytes (unterminated) or NULL */
unsigned char *mac_aton(const char *string){
static unsigned char result[6];