
#ifndef GLOBAL_H
#define GLOBAL_H

#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <signal.h>
#include <syslog.h>
#include <stdarg.h>
#include <fcntl.h>
#include <ctype.h>

#define BOOL int
#define TRUE 1
#define FALSE 0

#define NB_PARAMS 23                 /* number of parameters */
#define LINE_SIZE 1024               /* in the config file */
#define MAXLOGRECSIZE 2048           /* maximum log record size */

/*
 * Configuration parameters and their default values. 
 *
 */
char    boporttolisten [10] = "31337";
char    bomessage [512] = "Your attempt of breaking into this system has been logged. You are now on the black list.";
char    nbmessage [512] = "Your attempt of breaking into this system has been logged. You are now on the black list.";
char    logfile [255] = "stdout";
char    machinename [20] = "DEFAULT";
char    bofakever[10] = "1.20";
char    customrepliespath[255] = "fakebo.reply.";
char    executescript[255] = "abusemail !";

int     logconnection = 1 ;
int     logreceivedpackets = 2 ;
int     logsendingpackets = 0 ;
int     logtosyslog = 0 ;
int     lognotbopackets = 0 ;
int     sendfakereply = 1 ;
int     logtimeanddate = 1 ;
int     silentmode = 0 ;
int     bufferedlogging = 0 ;
int     usecustomreplies = 0 ;
int     toexecutescript = 0;

char	nbfakever[10] = "1.60";
int nbport = 12345;
char executescriptshell[255] = "/bin/sh";
int startasdaemon = 0;



/*
 * This is for parsing the config file and printing debug information. 
 *
 */
char    *keywords [NB_PARAMS]
= {"boport", "bomessage", "nbmessage", "logfile", "logconnection"
   , "logreceivedpackets", "logsendingpackets", "lognotbopackets"
   , "sendfakereply", "machinename", "logtimeanddate", "silentmode"
   , "bufferedlogging", "logtosyslog"
   , "bofakever", "usecustomreplies", "customrepliespath"
   , "toexecutescript", "executescript"
   , "nbport", "executescriptshell", "nbfakever","startasdaemon" };

void    *addresses [NB_PARAMS]
= { boporttolisten, bomessage, nbmessage, logfile, &logconnection
    , &logreceivedpackets, &logsendingpackets, &lognotbopackets
    , &sendfakereply, machinename, &logtimeanddate, &silentmode
    , &bufferedlogging, &logtosyslog
    , bofakever, &usecustomreplies, customrepliespath
    , &toexecutescript, executescript
    , &nbport, executescriptshell, nbfakever, &startasdaemon};
    
char    *in_formats [NB_PARAMS]
= {"%s", "\"%[^\"]\"", "\"%[^\"]\"", "\"%[^\"]\"", "%d", "%d", "%d",
   "%d", "%d"
   , "\"%[^\"]\"", "%d", "%d", "%d", "%d"
   , "\"%[^\"]\"", "%d", "\"%[^\"]\"", "%d", "%[^\n]"
   , "%d", "\"%[^\"]\"", "\"%[^\"]\"", "%d"};

char    *out_formats [NB_PARAMS]
= {"%s", "\"%s\"", "\"%s\"", "%s", "%d", "%d", "%d", "%d", "%d", "%s", "%d"
   , "%d", "%d", "%d"
   , "%s","%d","%s","%d","%s"
   , "%d", "%s", "%s", "%d"};

/*
 * Help the user.
 *
 */
char    usage []
= "Usage: %s [options]\n"
  "\t-c\tspecify the config file. By default, FakeBO will search for its\n"
  "\t\tconfig file in various places; see below the help\n"
  "\t-d\tprint debugging information.\n"
  "\t-i\tdebug BO packet numbers.\n"
  "\t-b\tstart FakeBO as a daemon.\n"
  "\t-a\tprint info about program.\n"
  "\t-h\tprint this help message.\n"
  "\n";

typedef unsigned char   byte ;

static volatile int stop = FALSE ;                  /* for signal handling */
FILE *fptolog;

#endif

