2000-07-02 20:43:55 +00:00
|
|
|
/* $Id* */
|
|
|
|
|
2000-09-27 05:38:29 +00:00
|
|
|
/* Settings you should not change -- see below for changeable ones */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-04-17 13:49:40 +00:00
|
|
|
/* Settings you can change */
|
|
|
|
|
|
|
|
#define DEFLINE 256
|
|
|
|
#define MAXLINE 65535
|
|
|
|
#define UDPMAX 65535
|
2000-06-29 11:48:49 +00:00
|
|
|
#ifdef HTTP
|
2000-04-17 13:49:40 +00:00
|
|
|
#define MAXTOREAD 150000
|
2000-06-29 11:48:49 +00:00
|
|
|
#endif
|
2000-09-27 05:38:29 +00:00
|
|
|
#ifdef SMTP
|
|
|
|
#define MAXSMTP 1024
|
|
|
|
#define MAXSMTPLINES 30
|
2000-04-17 11:36:29 +00:00
|
|
|
#endif
|
2000-09-27 05:38:29 +00:00
|
|
|
#define MAXNUMBER 20
|
2000-04-13 09:19:23 +00:00
|
|
|
|
|
|
|
/* Probably too many inclusions but this is to keep 'gcc -Wall' happy... */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <varargs.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
2000-11-04 12:36:37 +00:00
|
|
|
#ifdef OPENSSL
|
|
|
|
#include <openssl/crypto.h>
|
|
|
|
#include <openssl/x509.h>
|
|
|
|
#include <openssl/pem.h>
|
|
|
|
#include <openssl/ssl.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#endif
|
|
|
|
|
2000-04-13 09:19:23 +00:00
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SIGALRM /* Linux... */
|
|
|
|
#define SIGALRM 14 /* alarm clock timeout */
|
|
|
|
#endif
|
|
|
|
#ifndef SIGINT /* Linux... */
|
|
|
|
#define SIGINT 2 /* interrupt, generated from terminal special char */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INADDR_NONE /* SunOS */
|
|
|
|
#define INADDR_NONE (-1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* These entities should be in errno.h but some systems do not define
|
|
|
|
them. */
|
2000-04-17 11:36:29 +00:00
|
|
|
#ifdef DECL_SYS_ERRLIST
|
2000-04-13 09:19:23 +00:00
|
|
|
extern char *sys_errlist[];
|
|
|
|
#endif
|
2000-04-17 11:36:29 +00:00
|
|
|
#ifdef DECL_SYS_NERR
|
|
|
|
extern int sys_nerr;
|
|
|
|
#endif
|
2000-04-13 09:19:23 +00:00
|
|
|
|
2000-04-17 13:49:40 +00:00
|
|
|
/* If we have it, use it */
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
#define USE_SIGACTION 1
|
|
|
|
#endif
|
2000-04-17 14:31:25 +00:00
|
|
|
#ifdef HAVE_TTCP
|
|
|
|
#define USE_TTCP 1
|
|
|
|
#endif
|
2000-04-17 13:49:40 +00:00
|
|
|
|
2000-11-04 12:36:37 +00:00
|
|
|
#ifndef HEADER_INCLUDED
|
|
|
|
typedef union _CHANNEL {
|
|
|
|
FILE *fs;
|
|
|
|
#ifdef OPENSSL
|
|
|
|
SSL* ssl;
|
|
|
|
#endif
|
|
|
|
} CHANNEL;
|
|
|
|
#endif
|
|
|
|
|
2000-04-13 09:19:23 +00:00
|
|
|
struct timeval null_timeval;
|
|
|
|
struct timeval max_timeval;
|
|
|
|
|
|
|
|
#define ECHO_TCP_PORT "echo"
|
|
|
|
#define DISCARD_TCP_PORT "discard"
|
|
|
|
#define CHARACTER_GENERATOR_TCP_PORT "chargen"
|
2000-11-05 12:55:04 +00:00
|
|
|
#define DEFAULT_HTTP_TCP_PORT "HTTP"
|
|
|
|
#define DEFAULT_HTTPS_TCP_PORT "HTTPS"
|
2000-11-06 14:14:14 +00:00
|
|
|
#define DEFAULT_ICP_UDP_PORT "ICP"
|
2000-07-02 20:43:55 +00:00
|
|
|
/* #define ICP_UDP_PORT "icp" */ /* In config.h */
|
2000-04-13 09:19:23 +00:00
|
|
|
|
|
|
|
#define USE_ECHO 1
|
|
|
|
#define USE_DISCARD 2
|
|
|
|
#define USE_CHARGEN 3
|
|
|
|
#define USE_HTTP 4
|
|
|
|
#define USE_ICP 5
|
2000-09-27 05:38:29 +00:00
|
|
|
#define USE_SMTP 6
|
2000-04-13 09:19:23 +00:00
|
|
|
|
|
|
|
#define CHARGENERATED " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefg";
|
|
|
|
|
|
|
|
char *server;
|
|
|
|
|
|
|
|
/* My functions */
|
|
|
|
|
|
|
|
/* error.c */
|
|
|
|
void usage ();
|
|
|
|
void err_sys ();
|
|
|
|
void err_ret ();
|
|
|
|
void err_quit ();
|
|
|
|
char *sys_err_str ();
|
|
|
|
/* writen.c */
|
|
|
|
int writen ();
|
|
|
|
/* readline.c */
|
|
|
|
int readline ();
|
2000-11-04 12:36:37 +00:00
|
|
|
#ifdef OPENSSL
|
|
|
|
int SSL_readline ();
|
|
|
|
#endif
|
2000-04-13 09:19:23 +00:00
|
|
|
/* util.c */
|
|
|
|
char *random_string ();
|
|
|
|
void tvsub ();
|
|
|
|
void tvadd ();
|
|
|
|
void tvavg ();
|
|
|
|
void tvmin ();
|
|
|
|
void tvmax ();
|
|
|
|
double tv2double ();
|
|
|
|
/* http.c */
|
|
|
|
#ifdef HTTP
|
|
|
|
char *make_http_sendline ();
|
|
|
|
void find_server_and_port ();
|
2000-11-04 12:36:37 +00:00
|
|
|
/* This one has prototypes, for a very subtile compiler issue. */
|
|
|
|
int read_from_server (CHANNEL fs, short ssl);
|
2000-04-13 09:19:23 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ICP
|
|
|
|
#include "icp.h"
|
|
|
|
void *make_icp_sendline ();
|
|
|
|
int recv_icp ();
|
|
|
|
#ifndef HTTP
|
|
|
|
void find_server_and_port ();
|
|
|
|
int read_from_server ();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2000-09-27 05:38:29 +00:00
|
|
|
#ifdef SMTP
|
|
|
|
int smtp_read_response_from_server ();
|
|
|
|
#endif
|
2000-04-13 09:19:23 +00:00
|
|
|
|
|
|
|
extern char *progname;
|
|
|
|
|
|
|
|
extern unsigned short timeout_flag;
|
2000-11-04 12:36:37 +00:00
|
|
|
|
|
|
|
#ifndef HEADER_INCLUDED
|
|
|
|
#define HEADER_INCLUDED
|
|
|
|
#endif
|