Back to index

nagios-plugins  1.4.16
Defines | Functions | Variables
check_radius.c File Reference
#include "common.h"
#include "utils.h"
#include "netutils.h"
#include <radiusclient.h>

Go to the source code of this file.


#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)


int process_arguments (int, char **)
void print_help (void)
void print_usage (void)
int my_rc_read_config (char *)
int main (int argc, char **argv)


const char * progname = "check_radius"
const char * copyright = "2000-2008"
const char * email = ""
char * server = NULL
char * username = NULL
char * password = NULL
char * nasid = NULL
char * nasipaddress = NULL
char * expect = NULL
char * config_file = NULL
unsigned short port = PW_AUTH_UDP_PORT
int retries = 1
int verbose = FALSE
ENV * env = NULL

Define Documentation

#define my_rc_avpair_add (   a,
)    rc_avpair_add(a, b, c, d)

Definition at line 63 of file check_radius.c.

#define my_rc_buildreq (   a,
)    rc_buildreq(a,b,c,d,e,f)

Definition at line 61 of file check_radius.c.

#define my_rc_conf_str (   a)    rc_conf_str(a)

Definition at line 59 of file check_radius.c.

#define my_rc_own_ipaddress ( )    rc_own_ipaddress()

Definition at line 62 of file check_radius.c.

#define my_rc_read_dictionary (   a)    rc_read_dictionary(a)

Definition at line 64 of file check_radius.c.

#define my_rc_send_server (   a,
)    rc_send_server(a, b)

Definition at line 60 of file check_radius.c.


Definition at line 70 of file check_radius.c.

Function Documentation

int main ( int  argc,
char **  argv 

Definition at line 143 of file check_radius.c.

       UINT4 service;
       char msg[BUFFER_LEN];
       SEND_DATA data;
       int result = STATE_UNKNOWN;
       UINT4 client_id;
       char *str;

       setlocale (LC_ALL, "");
       bindtextdomain (PACKAGE, LOCALEDIR);
       textdomain (PACKAGE);

       /* Parse extra opts if any */
       argv=np_extra_opts (&argc, argv, progname);

       if (process_arguments (argc, argv) == ERROR)
              usage4 (_("Could not parse arguments"));

       str = strdup ("dictionary");
       if ((config_file && my_rc_read_config (config_file)) ||
                     my_rc_read_dictionary (my_rc_conf_str (str)))
              die (STATE_UNKNOWN, _("Config file error"));

       service = PW_AUTHENTICATE_ONLY;

       memset (&data, 0, sizeof(data));
       if (!(my_rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) &&
                            my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
                            my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0)
              die (STATE_UNKNOWN, _("Out of Memory?"));

       if (nasid != NULL) {
              if (!(my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0)))
                     die (STATE_UNKNOWN, _("Invalid NAS-Identifier"));

       if (nasipaddress != NULL) {
              if (rc_good_ipaddr (nasipaddress))
                     die (STATE_UNKNOWN, _("Invalid NAS-IP-Address"));
              if ((client_id = rc_get_ipaddr(nasipaddress)) == 0)
                     die (STATE_UNKNOWN, _("Invalid NAS-IP-Address"));
       } else {
              if ((client_id = my_rc_own_ipaddress ()) == 0)
                     die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address"));
       if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
              die (STATE_UNKNOWN, _("Invalid NAS-IP-Address"));

       my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,

       result = my_rc_send_server (&data, msg);
       rc_avpair_free (data.send_pairs);
       if (data.receive_pairs)
              rc_avpair_free (data.receive_pairs);

       if (result == TIMEOUT_RC)
              die (STATE_CRITICAL, _("Timeout"));
       if (result == ERROR_RC)
              die (STATE_CRITICAL, _("Auth Error"));
       if (result == REJECT_RC)
              die (STATE_WARNING, _("Auth Failed"));
       if (result == BADRESP_RC)
              die (STATE_WARNING, _("Bad Response"));
       if (expect && !strstr (msg, expect))
              die (STATE_WARNING, "%s", msg);
       if (result == OK_RC)
              die (STATE_OK, _("Auth OK"));
       (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result);
       die (STATE_UNKNOWN, "%s", msg);

Here is the call graph for this function:

int my_rc_read_config ( char *  a)

Definition at line 393 of file check_radius.c.

       rch = rc_read_config(a);
       return (rch == NULL) ? 1 : 0;
       return rc_read_config(a);

Here is the caller graph for this function:

void print_help ( void  )
void print_usage ( void  )

Definition at line 389 of file check_cpqarray.c.

  printf("cpqarrayd [options]\n");
  printf("   -h         prints this text\n");
  printf("   -d         enables debugging\n");
int process_arguments ( int  argc,
char **  argv 

Variable Documentation

char* config_file = NULL

Definition at line 81 of file check_radius.c.

const char* copyright = "2000-2008"

Definition at line 32 of file check_radius.c.

const char* email = ""

Definition at line 33 of file check_radius.c.

ENV* env = NULL

Definition at line 85 of file check_radius.c.

char* expect = NULL

Definition at line 80 of file check_radius.c.

char* nasid = NULL

Definition at line 78 of file check_radius.c.

char* nasipaddress = NULL

Definition at line 79 of file check_radius.c.

char* password = NULL

Definition at line 77 of file check_radius.c.

unsigned short port = PW_AUTH_UDP_PORT

Definition at line 82 of file check_radius.c.

const char* progname = "check_radius"

Definition at line 31 of file check_radius.c.

int retries = 1

Definition at line 83 of file check_radius.c.

char* server = NULL

Definition at line 75 of file check_radius.c.

char* username = NULL

Definition at line 76 of file check_radius.c.

int verbose = FALSE

Definition at line 84 of file check_radius.c.