~ubuntu-branches/ubuntu/precise/nagios-plugins/precise-proposed

« back to all changes in this revision

Viewing changes to plugins/check_tcp.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2004-06-15 15:37:48 UTC
  • Revision ID: james.westby@ubuntu.com-20040615153748-pq7702qdzghqfcns
Tags: upstream-1.3.1.0
ImportĀ upstreamĀ versionĀ 1.3.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *
 
3
 * This file is part of the Nagios Plugins.
 
4
 *
 
5
 * Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>
 
6
 *
 
7
 * The Nagios Plugins are free software; you can redistribute them
 
8
 * and/or modify them under the terms of the GNU General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
20
 *
 
21
 * $Id: check_tcp.c,v 1.13.2.3 2003/06/02 14:46:48 kdebisschop Exp $
 
22
 *
 
23
 *****************************************************************************/
 
24
 
 
25
#define REVISION "$Revision: 1.13.2.3 $"
 
26
#define DESCRIPTION "Check a TCP port"
 
27
#define AUTHOR "Ethan Galstad"
 
28
#define EMAIL "nagios@nagios.org"
 
29
#define COPYRIGHTDATE "2002"
 
30
 
 
31
#include "config.h"
 
32
#include "common.h"
 
33
#include "netutils.h"
 
34
#include "utils.h"
 
35
 
 
36
#ifdef HAVE_SSL_H
 
37
#include <rsa.h>
 
38
#include <crypto.h>
 
39
#include <x509.h>
 
40
#include <pem.h>
 
41
#include <ssl.h>
 
42
#include <err.h>
 
43
#endif
 
44
 
 
45
#ifdef HAVE_OPENSSL_SSL_H
 
46
#include <openssl/rsa.h>
 
47
#include <openssl/crypto.h>
 
48
#include <openssl/x509.h>
 
49
#include <openssl/pem.h>
 
50
#include <openssl/ssl.h>
 
51
#include <openssl/err.h>
 
52
#endif
 
53
 
 
54
#ifdef HAVE_SSL
 
55
SSL_CTX *ctx;
 
56
SSL *ssl;
 
57
int connect_SSL (void);
 
58
#endif
 
59
 
 
60
enum {
 
61
        TCP_PROTOCOL = 1,
 
62
        UDP_PROTOCOL = 2,
 
63
        MAXBUF = 1024
 
64
};
 
65
 
 
66
int process_arguments (int, char **);
 
67
void print_usage (void);
 
68
void print_help (void);
 
69
int my_recv (void);
 
70
 
 
71
char *progname = "check_tcp";
 
72
char *SERVICE = NULL;
 
73
char *SEND = NULL;
 
74
char *EXPECT = NULL;
 
75
char *QUIT = NULL;
 
76
int PROTOCOL = 0;
 
77
int PORT = 0;
 
78
 
 
79
int server_port = 0;
 
80
char *server_address = NULL;
 
81
char *server_send = NULL;
 
82
char *server_quit = NULL;
 
83
char **server_expect = NULL;
 
84
int server_expect_count = 0;
 
85
int maxbytes = 0;
 
86
char **warn_codes = NULL;
 
87
int warn_codes_count = 0;
 
88
char **crit_codes = NULL;
 
89
int crit_codes_count = 0;
 
90
int delay = 0;
 
91
double warning_time = 0;
 
92
int check_warning_time = FALSE;
 
93
double critical_time = 0;
 
94
int check_critical_time = FALSE;
 
95
double elapsed_time = 0;
 
96
int verbose = FALSE;
 
97
int use_ssl = FALSE;
 
98
int sd = 0;
 
99
char *buffer = "";
 
100
 
 
101
int
 
102
main (int argc, char **argv)
 
103
{
 
104
        int result;
 
105
        int i;
 
106
        char *status = "";
 
107
        struct timeval tv;
 
108
 
 
109
        if (strstr (argv[0], "check_udp")) {
 
110
                asprintf (&progname, "check_udp");
 
111
                asprintf (&SERVICE, "UDP");
 
112
                SEND = NULL;
 
113
                EXPECT = NULL;
 
114
                QUIT = NULL;
 
115
                PROTOCOL = UDP_PROTOCOL;
 
116
                PORT = 0;
 
117
        }
 
118
        else if (strstr (argv[0], "check_tcp")) {
 
119
                asprintf (&progname, "check_tcp");
 
120
                asprintf (&SERVICE, "TCP");
 
121
                SEND = NULL;
 
122
                EXPECT = NULL;
 
123
                QUIT = NULL;
 
124
                PROTOCOL = TCP_PROTOCOL;
 
125
                PORT = 0;
 
126
        }
 
127
        else if (strstr (argv[0], "check_ftp")) {
 
128
                asprintf (&progname, "check_ftp");
 
129
                asprintf (&SERVICE, "FTP");
 
130
                SEND = NULL;
 
131
                asprintf (&EXPECT, "220");
 
132
                asprintf (&QUIT, "QUIT\r\n");
 
133
                PROTOCOL = TCP_PROTOCOL;
 
134
                PORT = 21;
 
135
        }
 
136
        else if (strstr (argv[0], "check_smtp")) {
 
137
                asprintf (&progname, "check_smtp");
 
138
                asprintf (&SERVICE, "SMTP");
 
139
                SEND = NULL;
 
140
                asprintf (&EXPECT, "220");
 
141
                asprintf (&QUIT, "QUIT\r\n");
 
142
                PROTOCOL = TCP_PROTOCOL;
 
143
                PORT = 25;
 
144
        }
 
145
        else if (strstr (argv[0], "check_pop")) {
 
146
                asprintf (&progname, "check_pop");
 
147
                asprintf (&SERVICE, "POP");
 
148
                SEND = NULL;
 
149
                asprintf (&EXPECT, "+OK");
 
150
                asprintf (&QUIT, "QUIT\r\n");
 
151
                PROTOCOL = TCP_PROTOCOL;
 
152
                PORT = 110;
 
153
        }
 
154
        else if (strstr (argv[0], "check_imap")) {
 
155
                asprintf (&progname, "check_imap");
 
156
                asprintf (&SERVICE, "IMAP");
 
157
                SEND = NULL;
 
158
                asprintf (&EXPECT, "* OK");
 
159
                asprintf (&QUIT, "a1 LOGOUT\r\n");
 
160
                PROTOCOL = TCP_PROTOCOL;
 
161
                PORT = 143;
 
162
        }
 
163
#ifdef HAVE_SSL
 
164
        else if (strstr(argv[0],"check_simap")) {
 
165
                asprintf (&progname, "check_simap");
 
166
                asprintf (&SERVICE, "SIMAP");
 
167
                SEND=NULL;
 
168
                asprintf (&EXPECT, "* OK");
 
169
                asprintf (&QUIT, "a1 LOGOUT\r\n");
 
170
                PROTOCOL=TCP_PROTOCOL;
 
171
                use_ssl=TRUE;
 
172
                PORT=993;
 
173
        }
 
174
        else if (strstr(argv[0],"check_spop")) {
 
175
                asprintf (&progname, "check_spop");
 
176
                asprintf (&SERVICE, "SPOP");
 
177
                SEND=NULL;
 
178
                asprintf (&EXPECT, "+OK");
 
179
                asprintf (&QUIT, "QUIT\r\n");
 
180
                PROTOCOL=TCP_PROTOCOL;
 
181
                use_ssl=TRUE;
 
182
                PORT=995;
 
183
        }
 
184
#endif
 
185
        else if (strstr (argv[0], "check_nntp")) {
 
186
                asprintf (&progname, "check_nntp");
 
187
                asprintf (&SERVICE, "NNTP");
 
188
                SEND = NULL;
 
189
                EXPECT = NULL;
 
190
                server_expect = realloc (server_expect, ++server_expect_count);
 
191
                asprintf (&server_expect[server_expect_count - 1], "200");
 
192
                server_expect = realloc (server_expect, ++server_expect_count);
 
193
                asprintf (&server_expect[server_expect_count - 1], "201");
 
194
                asprintf (&QUIT, "QUIT\r\n");
 
195
                PROTOCOL = TCP_PROTOCOL;
 
196
                PORT = 119;
 
197
        }
 
198
        else {
 
199
                usage ("ERROR: Generic check_tcp called with unknown service\n");
 
200
        }
 
201
 
 
202
        asprintf (&server_address, "127.0.0.1");
 
203
        server_port = PORT;
 
204
        server_send = SEND;
 
205
        server_quit = QUIT;
 
206
 
 
207
        if (process_arguments (argc, argv) == ERROR)
 
208
                usage ("Could not parse arguments\n");
 
209
 
 
210
        /* use default expect if none listed in process_arguments() */
 
211
        if (EXPECT && server_expect_count == 0) {
 
212
                server_expect = malloc (++server_expect_count);
 
213
                server_expect[server_expect_count - 1] = EXPECT;
 
214
        }
 
215
 
 
216
        /* initialize alarm signal handling */
 
217
        signal (SIGALRM, socket_timeout_alarm_handler);
 
218
 
 
219
        /* set socket timeout */
 
220
        alarm (socket_timeout);
 
221
 
 
222
        /* try to connect to the host at the given port number */
 
223
        gettimeofday (&tv, NULL);
 
224
#ifdef HAVE_SSL
 
225
        if (use_ssl)
 
226
                result = connect_SSL ();
 
227
        else
 
228
#endif
 
229
                {
 
230
                        if (PROTOCOL == UDP_PROTOCOL)
 
231
                                result = my_udp_connect (server_address, server_port, &sd);
 
232
                        else                                                                                                    /* default is TCP */
 
233
                                result = my_tcp_connect (server_address, server_port, &sd);
 
234
                }
 
235
 
 
236
        if (result == STATE_CRITICAL)
 
237
                return STATE_CRITICAL;
 
238
 
 
239
        if (server_send != NULL) {              /* Something to send? */
 
240
                asprintf (&server_send, "%s\r\n", server_send);
 
241
#ifdef HAVE_SSL
 
242
                if (use_ssl)
 
243
                        SSL_write(ssl, server_send, strlen (server_send));
 
244
                else
 
245
#endif
 
246
                        send (sd, server_send, strlen (server_send), 0);
 
247
        }
 
248
 
 
249
        if (delay > 0) {
 
250
                tv.tv_sec += delay;
 
251
                sleep (delay);
 
252
        }
 
253
 
 
254
        if (server_send || server_expect_count > 0) {
 
255
 
 
256
                buffer = malloc (MAXBUF);
 
257
                memset (buffer, '\0', MAXBUF);
 
258
                /* watch for the expect string */
 
259
                while ((i = my_recv ()) > 0) {
 
260
                        buffer[i] = '\0';
 
261
                        asprintf (&status, "%s%s", status, buffer);
 
262
                        if (buffer[i-2] == '\r' && buffer[i-1] == '\n')
 
263
                                break;
 
264
                        if (maxbytes>0 && strlen(status)>=maxbytes)
 
265
                                break;
 
266
                }
 
267
 
 
268
                /* return a CRITICAL status if we couldn't read any data */
 
269
                if (status == NULL)
 
270
                        terminate (STATE_CRITICAL, "No data received from host\n");
 
271
 
 
272
                strip (status);
 
273
 
 
274
                if (status && verbose)
 
275
                        printf ("%s\n", status);
 
276
 
 
277
                if (server_expect_count > 0) {
 
278
                        for (i = 0;; i++) {
 
279
                                if (verbose)
 
280
                                        printf ("%d %d\n", i, server_expect_count);
 
281
                                if (i >= server_expect_count)
 
282
                                        terminate (STATE_WARNING, "Invalid response from host\n");
 
283
                                if (strstr (status, server_expect[i]))
 
284
                                        break;
 
285
                        }
 
286
                }
 
287
        }
 
288
 
 
289
        if (server_quit != NULL)
 
290
#ifdef HAVE_SSL
 
291
                if (use_ssl) {
 
292
                        SSL_write (ssl, QUIT, strlen (QUIT));
 
293
                        SSL_shutdown (ssl);
 
294
                        SSL_free (ssl);
 
295
                        SSL_CTX_free (ctx);
 
296
                }
 
297
                else
 
298
#endif
 
299
                send (sd, server_quit, strlen (server_quit), 0);
 
300
 
 
301
        /* close the connection */
 
302
        if (sd)
 
303
                close (sd);
 
304
 
 
305
        elapsed_time = delta_time (tv);
 
306
 
 
307
        if (check_critical_time == TRUE && elapsed_time > critical_time)
 
308
                result = STATE_CRITICAL;
 
309
        else if (check_warning_time == TRUE && elapsed_time > warning_time)
 
310
                result = STATE_WARNING;
 
311
 
 
312
        /* reset the alarm */
 
313
        alarm (0);
 
314
 
 
315
        printf
 
316
                ("%s %s - %7.3f second response time on port %d",
 
317
                 SERVICE,
 
318
                 state_text (result), elapsed_time, server_port);
 
319
 
 
320
        if (status && strlen(status) > 0)
 
321
                printf (" [%s]", status);
 
322
 
 
323
        printf ("|time=%7.3f\n", elapsed_time);
 
324
 
 
325
        return result;
 
326
}
 
327
 
 
328
 
 
329
 
 
330
 
 
331
 
 
332
 
 
333
 
 
334
/* process command-line arguments */
 
335
int
 
336
process_arguments (int argc, char **argv)
 
337
{
 
338
        int c;
 
339
 
 
340
#ifdef HAVE_GETOPT_H
 
341
        int option_index = 0;
 
342
        static struct option long_options[] = {
 
343
                {"hostname", required_argument, 0, 'H'},
 
344
                {"critical-time", required_argument, 0, 'c'},
 
345
                {"warning-time", required_argument, 0, 'w'},
 
346
                {"critical-codes", required_argument, 0, 'C'},
 
347
                {"warning-codes", required_argument, 0, 'W'},
 
348
                {"timeout", required_argument, 0, 't'},
 
349
                {"protocol", required_argument, 0, 'P'},
 
350
                {"port", required_argument, 0, 'p'},
 
351
                {"send", required_argument, 0, 's'},
 
352
                {"expect", required_argument, 0, 'e'},
 
353
                {"maxbytes", required_argument, 0, 'm'},
 
354
                {"quit", required_argument, 0, 'q'},
 
355
                {"delay", required_argument, 0, 'd'},
 
356
                {"verbose", no_argument, 0, 'v'},
 
357
                {"version", no_argument, 0, 'V'},
 
358
                {"help", no_argument, 0, 'h'},
 
359
                {0, 0, 0, 0}
 
360
        };
 
361
#endif
 
362
 
 
363
        if (argc < 2)
 
364
                usage ("No arguments found\n");
 
365
 
 
366
        /* backwards compatibility */
 
367
        for (c = 1; c < argc; c++) {
 
368
                if (strcmp ("-to", argv[c]) == 0)
 
369
                        strcpy (argv[c], "-t");
 
370
                else if (strcmp ("-wt", argv[c]) == 0)
 
371
                        strcpy (argv[c], "-w");
 
372
                else if (strcmp ("-ct", argv[c]) == 0)
 
373
                        strcpy (argv[c], "-c");
 
374
        }
 
375
 
 
376
        if (!is_option (argv[1])) {
 
377
                server_address = argv[1];
 
378
                argv[1] = argv[0];
 
379
                argv = &argv[1];
 
380
                argc--;
 
381
        }
 
382
 
 
383
        while (1) {
 
384
#ifdef HAVE_GETOPT_H
 
385
                c =
 
386
                        getopt_long (argc, argv, "+hVvH:s:e:q:m:c:w:t:p:C:W:d:S", long_options,
 
387
                                                                         &option_index);
 
388
#else
 
389
                c = getopt (argc, argv, "+hVvH:s:e:q:m:c:w:t:p:C:W:d:S");
 
390
#endif
 
391
 
 
392
                if (c == -1 || c == EOF || c == 1)
 
393
                        break;
 
394
 
 
395
                switch (c) {
 
396
                case '?':                 /* print short usage statement if args not parsable */
 
397
                        printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 
398
                        print_usage ();
 
399
                        exit (STATE_UNKNOWN);
 
400
                case 'h':                 /* help */
 
401
                        print_help ();
 
402
                        exit (STATE_OK);
 
403
                case 'V':                 /* version */
 
404
                        print_revision (progname, "$Revision: 1.13.2.3 $");
 
405
                        exit (STATE_OK);
 
406
                case 'v':                 /* verbose mode */
 
407
                        verbose = TRUE;
 
408
                        break;
 
409
                case 'H':                 /* hostname */
 
410
                        if (is_host (optarg) == FALSE)
 
411
                                usage2 ("invalid host name or address", optarg);
 
412
                        server_address = optarg;
 
413
                        break;
 
414
                case 'c':                 /* critical */
 
415
                        if (!is_intnonneg (optarg))
 
416
                                usage ("Critical threshold must be a nonnegative integer\n");
 
417
                        critical_time = strtod (optarg, NULL);
 
418
                        check_critical_time = TRUE;
 
419
                        break;
 
420
                case 'w':                 /* warning */
 
421
                        if (!is_intnonneg (optarg))
 
422
                                usage ("Warning threshold must be a nonnegative integer\n");
 
423
                        warning_time = strtod (optarg, NULL);
 
424
                        check_warning_time = TRUE;
 
425
                        break;
 
426
                case 'C':
 
427
                        crit_codes = realloc (crit_codes, ++crit_codes_count);
 
428
                        crit_codes[crit_codes_count - 1] = optarg;
 
429
                        break;
 
430
                case 'W':
 
431
                        warn_codes = realloc (warn_codes, ++warn_codes_count);
 
432
                        warn_codes[warn_codes_count - 1] = optarg;
 
433
                        break;
 
434
                case 't':                 /* timeout */
 
435
                        if (!is_intpos (optarg))
 
436
                                usage ("Timeout interval must be a positive integer\n");
 
437
                        socket_timeout = atoi (optarg);
 
438
                        break;
 
439
                case 'p':                 /* port */
 
440
                        if (!is_intpos (optarg))
 
441
                                usage ("Server port must be a positive integer\n");
 
442
                        server_port = atoi (optarg);
 
443
                        break;
 
444
                case 's':
 
445
                        server_send = optarg;
 
446
                        break;
 
447
                case 'e': /* expect string (may be repeated) */
 
448
                        EXPECT = NULL;
 
449
                        if (server_expect_count == 0)
 
450
                                server_expect = malloc (++server_expect_count);
 
451
                        else
 
452
                                server_expect = realloc (server_expect, ++server_expect_count);
 
453
                        server_expect[server_expect_count - 1] = optarg;
 
454
                        break;
 
455
                case 'm':
 
456
                        if (!is_intpos (optarg))
 
457
                                usage ("Maxbytes must be a positive integer\n");
 
458
                        maxbytes = atoi (optarg);
 
459
                case 'q':
 
460
                        server_quit = optarg;
 
461
                        break;
 
462
                case 'd':
 
463
                        if (is_intpos (optarg))
 
464
                                delay = atoi (optarg);
 
465
                        else
 
466
                                usage ("Delay must be a positive integer\n");
 
467
                        break;
 
468
                case 'S':
 
469
#ifndef HAVE_SSL
 
470
                        terminate (STATE_UNKNOWN,
 
471
                                "SSL support not available. Install OpenSSL and recompile.");
 
472
#endif
 
473
                        use_ssl = TRUE;
 
474
                        break;
 
475
                }
 
476
        }
 
477
 
 
478
        if (server_address == NULL)
 
479
                usage ("You must provide a server address\n");
 
480
 
 
481
        return OK;
 
482
}
 
483
 
 
484
 
 
485
 
 
486
 
 
487
 
 
488
void
 
489
print_usage (void)
 
490
{
 
491
        printf
 
492
                ("Usage: %s -H host -p port [-w warn_time] [-c crit_time] [-s send_string]\n"
 
493
                 "         [-e expect_string] [-q quit_string] [-m maxbytes] [-d delay]\n"
 
494
                 "         [-t to_sec] [-v]\n", progname);
 
495
}
 
496
 
 
497
 
 
498
 
 
499
 
 
500
 
 
501
void
 
502
print_help (void)
 
503
{
 
504
        print_revision (progname, "$Revision: 1.13.2.3 $");
 
505
        printf
 
506
                ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n"
 
507
                 "This plugin tests %s connections with the specified host.\n\n",
 
508
                 SERVICE);
 
509
        print_usage ();
 
510
        printf
 
511
                ("Options:\n"
 
512
                 " -H, --hostname=ADDRESS\n"
 
513
                 "    Host name argument for servers using host headers (use numeric\n"
 
514
                 "    address if possible to bypass DNS lookup).\n"
 
515
                 " -p, --port=INTEGER\n"
 
516
                 "    Port number\n"
 
517
                 " -s, --send=STRING\n"
 
518
                 "    String to send to the server\n"
 
519
                 " -e, --expect=STRING\n"
 
520
                 "    String to expect in server response\n"
 
521
                 " -q, --quit=STRING\n"
 
522
                 "    String to send server to initiate a clean close of the connection\n"
 
523
                 " -m, --maxbytes=INTEGER\n"
 
524
                 "    Close connection once more than this number of bytes are received\n"
 
525
                 " -d, --delay=INTEGER\n"
 
526
                 "    Seconds to wait between sending string and polling for response\n"
 
527
                 " -w, --warning=DOUBLE\n"
 
528
                 "    Response time to result in warning status (seconds)\n"
 
529
                 " -c, --critical=DOUBLE\n"
 
530
                 "    Response time to result in critical status (seconds)\n"
 
531
                 " -t, --timeout=INTEGER\n"
 
532
                 "    Seconds before connection times out (default: %d)\n"
 
533
                 " -v, --verbose"
 
534
                 "    Show details for command-line debugging (do not use with nagios server)\n"
 
535
                 " -h, --help\n"
 
536
                 "    Print detailed help screen\n"
 
537
                 " -V, --version\n"
 
538
                 "    Print version information\n", DEFAULT_SOCKET_TIMEOUT);
 
539
}
 
540
 
 
541
/*
 
542
                 " -W, --warning-codes=STRING\n"
 
543
                 "    \n"
 
544
                 " -C, --critical-code=STRING\n"
 
545
                 "    \n"
 
546
*/
 
547
 
 
548
#ifdef HAVE_SSL
 
549
int
 
550
connect_SSL (void)
 
551
{
 
552
  SSL_METHOD *meth;
 
553
 
 
554
  /* Initialize SSL context */
 
555
  SSLeay_add_ssl_algorithms ();
 
556
  meth = SSLv2_client_method ();
 
557
  SSL_load_error_strings ();
 
558
  if ((ctx = SSL_CTX_new (meth)) == NULL)
 
559
    {
 
560
      printf ("ERROR: Cannot create SSL context.\n");
 
561
      return STATE_CRITICAL;
 
562
    }
 
563
 
 
564
  /* Initialize alarm signal handling */
 
565
  signal (SIGALRM, socket_timeout_alarm_handler);
 
566
 
 
567
  /* Set socket timeout */
 
568
  alarm (socket_timeout);
 
569
 
 
570
  /* Save start time */
 
571
  time (&start_time);
 
572
 
 
573
  /* Make TCP connection */
 
574
  if (my_tcp_connect (server_address, server_port, &sd) == STATE_OK)
 
575
    {
 
576
    /* Do the SSL handshake */
 
577
      if ((ssl = SSL_new (ctx)) != NULL)
 
578
      {
 
579
        SSL_set_fd (ssl, sd);
 
580
        if (SSL_connect (ssl) != -1)
 
581
          return OK;
 
582
        ERR_print_errors_fp (stderr);
 
583
      }
 
584
      else
 
585
      {
 
586
        printf ("ERROR: Cannot initiate SSL handshake.\n");
 
587
      }
 
588
      SSL_free (ssl);
 
589
    }
 
590
 
 
591
  SSL_CTX_free (ctx);
 
592
  close (sd);
 
593
 
 
594
  return STATE_CRITICAL;
 
595
}
 
596
#endif
 
597
 
 
598
 
 
599
 
 
600
int
 
601
my_recv (void)
 
602
{
 
603
        int i;
 
604
 
 
605
#ifdef HAVE_SSL
 
606
        if (use_ssl) {
 
607
                i = SSL_read (ssl, buffer, MAXBUF - 1);
 
608
        }
 
609
        else {
 
610
#endif
 
611
                i = read (sd, buffer, MAXBUF - 1);
 
612
#ifdef HAVE_SSL
 
613
        }
 
614
#endif
 
615
 
 
616
        return i;
 
617
}