1997-10-26 01:04:02 +00:00
|
|
|
/*
|
1997-11-22 03:37:54 +00:00
|
|
|
* $Id: defs.c,v 1.4 1997/11/18 00:19:30 brian Exp $
|
1997-10-26 01:04:02 +00:00
|
|
|
*/
|
|
|
|
|
1997-11-17 00:42:41 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <stdlib.h>
|
1997-11-11 22:58:14 +00:00
|
|
|
#include <string.h>
|
1997-11-22 03:37:54 +00:00
|
|
|
#include <time.h>
|
1997-11-17 00:42:41 +00:00
|
|
|
#include <unistd.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
1997-11-22 03:37:54 +00:00
|
|
|
#include "command.h"
|
1997-11-17 00:42:41 +00:00
|
|
|
#include "mbuf.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "loadalias.h"
|
|
|
|
#include "vars.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
|
|
|
|
int mode = MODE_INTER;
|
|
|
|
int BGFiledes[2] = { -1, -1 };
|
|
|
|
int modem = -1;
|
|
|
|
int tun_in = -1;
|
|
|
|
int tun_out = -1;
|
|
|
|
int netfd = -1;
|
1997-11-11 22:58:14 +00:00
|
|
|
|
|
|
|
static char dstsystem[50];
|
|
|
|
|
|
|
|
void
|
|
|
|
SetLabel(const char *label)
|
|
|
|
{
|
|
|
|
if (label)
|
|
|
|
strncpy(dstsystem, label, sizeof dstsystem);
|
|
|
|
else
|
|
|
|
*dstsystem = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
GetLabel()
|
|
|
|
{
|
|
|
|
return *dstsystem ? dstsystem : NULL;
|
|
|
|
}
|
1997-10-26 01:04:02 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
randinit()
|
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
#ifdef __FreeBSD__
|
1997-10-26 01:04:02 +00:00
|
|
|
static int initdone;
|
|
|
|
|
|
|
|
if (!initdone) {
|
|
|
|
initdone = 1;
|
|
|
|
srandomdev();
|
|
|
|
}
|
1997-11-22 03:37:54 +00:00
|
|
|
#else
|
|
|
|
srandom(time(NULL)^getpid());
|
|
|
|
#endif
|
1997-10-26 01:04:02 +00:00
|
|
|
}
|
1997-11-17 00:42:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
GetShortHost()
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (gethostname(VarShortHost, sizeof(VarShortHost))) {
|
|
|
|
LogPrintf(LogERROR, "GetShortHost: gethostbyname: %s\n", strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((p = strchr(VarShortHost, '.')))
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
1997-11-18 00:19:34 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
DropClient()
|
|
|
|
{
|
|
|
|
FILE *oVarTerm;
|
|
|
|
|
|
|
|
if (VarTerm && !(mode & MODE_INTER)) {
|
|
|
|
oVarTerm = VarTerm;
|
|
|
|
VarTerm = 0;
|
|
|
|
if (oVarTerm)
|
|
|
|
fclose(oVarTerm);
|
|
|
|
close(netfd);
|
|
|
|
netfd = -1;
|
|
|
|
LogPrintf(LogPHASE, "Client connection closed.\n");
|
|
|
|
}
|
|
|
|
}
|