-/* protos */
-static int gethostaddr(const char * name);
-static void read_hosts(const char * cfg_file_name);
-static void init_hosts(void);
-static void get_response(void);
-static void pinger(int);
-static int in_cksum(unsigned short * addr, int len);
-static void read_icmp_data(struct monitor_host * p);
-static void tvsub(struct timeval * out, struct timeval * in);
-static int gcd(int x, int y);
-
-/* globals */
-static struct monitor_host ** hosts = NULL;
-static int isVerbose = 0;
-static int keepBanging = 0;
-static unsigned short ident;
-static int send_delay = 1;
-
-int
-main(int argc, char ** argv)
-{
- extern char * optarg;
- extern int optind;
- char * cfgfile = NULL;
- int param;
-
- while ((param = getopt(argc, argv, "rvf:")) != -1) {
- switch(param) {
- case 'v':
- isVerbose = 1;
- break;
- case 'r':
- keepBanging = 1;
- break;
- case 'f':
- cfgfile=strdup(optarg);
- break;
- default:
- fprintf(stderr,"Usage: icmpmonitor [-v] [-r] [-f cfgfile]\n");
- exit(EXIT_FAILURE);
- }
- }
-
- if (!cfgfile) {
- fprintf(stderr, "ERROR: No config file specified.\n");
- exit(EXIT_FAILURE);
- }
-
- read_hosts(cfgfile);
-
- init_hosts();
-
- ident = getpid() & 0xFFFF;
-
- signal(SIGALRM, pinger);
- alarm(send_delay);
-
- get_response();
-
- exit(EXIT_SUCCESS);
-}
+/* Globals */
+ /* Since the program is based around signals, a linked list of hosts is maintained here. */
+ static struct monitor_host ** hosts = NULL;
+ /* Set by command line flags. */
+ static bool verbose = false;
+ static bool retry_down_cmd = false;
+ /* TODO: Get rid of this global. */
+ static int send_delay = 1;