aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_radius.c
diff options
context:
space:
mode:
authorGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2016-11-17 17:22:37 +0100
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2016-11-17 17:22:37 +0100
commit487a9d0a8b0700c06857d4bc35423db4e4dbc3d6 (patch)
treeabfdc545a658550e32a69f0dfdd8ace3aa9f5a41 /plugins/check_radius.c
parentbfc745a79d4912479b725c00375aa171f8528ca2 (diff)
downloadmonitoring-plugins-487a9d0a8b0700c06857d4bc35423db4e4dbc3d6.tar.gz
check_radius: Replace functions removed in radcli
The radcli library no longer offers the rc_get_ipaddr(), rc_good_ipaddr(), and rc_own_ipaddress() functions.
Diffstat (limited to 'plugins/check_radius.c')
-rw-r--r--plugins/check_radius.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 518f1588..b3b8c829 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -62,14 +62,12 @@ void print_usage (void);
#else
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
#endif
-#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
#else
#define my_rc_conf_str(a) rc_conf_str(a)
#define my_rc_send_server(a,b) rc_send_server(a, b)
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
-#define my_rc_own_ipaddress() rc_own_ipaddress()
#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
#define my_rc_read_dictionary(a) rc_read_dictionary(a)
#endif
@@ -155,6 +153,8 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
int
main (int argc, char **argv)
{
+ struct sockaddr_storage ss;
+ char name[HOST_NAME_MAX];
char msg[BUFFER_LEN];
SEND_DATA data;
int result = STATE_UNKNOWN;
@@ -190,15 +190,14 @@ main (int argc, char **argv)
die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
}
- if (nasipaddress != NULL) {
- if (rc_good_ipaddr (nasipaddress))
- die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
- if ((client_id = rc_get_ipaddr(nasipaddress)) == 0)
- die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
- } else {
- if ((client_id = my_rc_own_ipaddress ()) == 0)
- die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
+ if (nasipaddress == NULL) {
+ if (gethostname (name, sizeof(name)) != 0)
+ die (STATE_UNKNOWN, _("gethostname() failed!\n"));
+ nasipaddress = name;
}
+ if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */
+ die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
+ client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr);
if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));