summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 8a42a64..8a2dcc5 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -57,12 +57,16 @@ SSL *ssl;
57int connect_SSL (void); 57int connect_SSL (void);
58#endif 58#endif
59 59
60#define TCP_PROTOCOL 1 60enum {
61#define UDP_PROTOCOL 2 61 TCP_PROTOCOL = 1,
62 UDP_PROTOCOL = 2,
63 MAXBUF = 1024
64};
62 65
63int process_arguments (int, char **); 66int process_arguments (int, char **);
64void print_usage (void); 67void print_usage (void);
65void print_help (void); 68void print_help (void);
69int my_recv (void);
66 70
67char *progname = "check_tcp"; 71char *progname = "check_tcp";
68char *SERVICE = NULL; 72char *SERVICE = NULL;
@@ -91,13 +95,13 @@ double elapsed_time = 0;
91int verbose = FALSE; 95int verbose = FALSE;
92int use_ssl = FALSE; 96int use_ssl = FALSE;
93int sd = 0; 97int sd = 0;
98char *buffer = "";
94 99
95int 100int
96main (int argc, char **argv) 101main (int argc, char **argv)
97{ 102{
98 int result; 103 int result;
99 int i; 104 int i;
100 char *buffer = "";
101 char *status = ""; 105 char *status = "";
102 struct timeval tv; 106 struct timeval tv;
103 107
@@ -248,15 +252,15 @@ main (int argc, char **argv)
248 252
249 if (server_send || server_expect_count > 0) { 253 if (server_send || server_expect_count > 0) {
250 254
251 buffer = malloc (MAX_INPUT_BUFFER); 255 buffer = malloc (MAXBUF);
256 memset (buffer, '\0', MAXBUF);
252 /* watch for the expect string */ 257 /* watch for the expect string */
253#ifdef HAVE_SSL 258 while ((i = my_recv ()) > 0) {
254 if (use_ssl && SSL_read (ssl, buffer, MAX_INPUT_BUFFER - 1) > 0) 259 buffer[i] = '\0';
255 asprintf (&status, "%s%s", status, buffer); 260 asprintf (&status, "%s%s", status, buffer);
256 else 261 if (buffer[i-2] == '\r' && buffer[i-1] == '\n')
257#endif 262 break;
258 if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) > 0) 263 }
259 asprintf (&status, "%s%s", status, buffer);
260 264
261 /* return a CRITICAL status if we couldn't read any data */ 265 /* return a CRITICAL status if we couldn't read any data */
262 if (status == NULL) 266 if (status == NULL)
@@ -279,7 +283,7 @@ main (int argc, char **argv)
279 } 283 }
280 } 284 }
281 285
282 if (server_quit) 286 if (server_quit != NULL)
283#ifdef HAVE_SSL 287#ifdef HAVE_SSL
284 if (use_ssl) { 288 if (use_ssl) {
285 SSL_write (ssl, QUIT, strlen (QUIT)); 289 SSL_write (ssl, QUIT, strlen (QUIT));
@@ -572,3 +576,23 @@ connect_SSL (void)
572} 576}
573#endif 577#endif
574 578
579
580
581int
582my_recv (void)
583{
584 int i;
585
586#ifdef HAVE_SSL
587 if (use_ssl) {
588 i = SSL_read (ssl, buffer, MAXBUF - 1);
589 }
590 else {
591#endif
592 i = read (sd, buffer, MAXBUF - 1);
593#ifdef HAVE_SSL
594 }
595#endif
596
597 return i;
598}