1 /*
2 ** portmon.h -- Obligatory header file
3 ** Copyright (C) 2002 Nik Reiman <nik@aboleo.net>
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA
18 */
19 
20 #ifdef HAVE_STRINGS_H
21 #include <strings.h>
22 #endif
23 #include <sys/types.h>
24 #include <netinet/in.h>
25 #include <time.h>
26 #include <sys/time.h>
27 
28 #define MAXINT 32768
29 #define STRSMALL 32
30 #define STRMED 128
31 #define STRLARGE 512
32 
33 // flags
34 extern int report_flag;
35 extern int daemonize_flag;
36 
37 struct port
38 {
39   int port;
40   int is_down;
41   time_t downtime;
42   struct sockaddr_in addr;
43 };
44 
45 // create an array of hosts
46 struct host_struct
47 {
48   char name[STRMED];
49   struct port ports[STRSMALL];
50   int num_ports;
51 };
52 extern struct host_struct *hosts;
53 
54 // place to hold error messages
55 extern char *err_msg;
56 // place we log crap
57 extern char logfile[STRLARGE];
58 // timeout (seconds)
59 extern int timeout;
60 // verbose mode
61 extern int verbose;
62 
63 // Functions in various files
64 
65 // portmon.c
66 char *get_time (time_t cur_time);
67 int log_write (char *msg);
68 void version (void);
69 void portmon_exit (int signal);
70 char *get_time (time_t cur_time);
71 void help (void);
72 
73 // action.c
74 int err_action(char *hostname, char *err_msg);
75 
76 // tcp_ping.c
77 int tcp_ping (struct sockaddr_in addr, int port);
78 void alarm_signal (int sig);
79 
80 // icmp_ping.c
81 int icmp_ping (struct sockaddr_in addr);
82 int in_cksum (unsigned short *buf, int len);
83 int wait_icmp (struct sockaddr_in *src);
84 void ms_to_tv (int ms, struct timeval *tv);
85 int send_echo (struct sockaddr_in *dest);
86 int tv_to_ms (struct timeval *tv);
87 
88 // report.c
89 int report (int num_hosts, int num_probes, int lag_timeout, char *output_fmt);
90 int format_output(char *output_fmt, char *out_str, char *hostname, int port, int lag, char status, char *wd_status);
91 
92 // config.c
93 int read_config (char *config_name);
94 
95 // exec_proc.c
96 int exec_proc(char *command, time_t cur_time, char *hostname, char *err_msg);
97