1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00
freebsd/usr.sbin/ppp/defs.c
Brian Somers b6e82f33ef Fix prototypes.
Remove extraneous decls.
Add ``const'' to several places.
Allow ``make NOALIAS=1'' to remove IP aliasing.
Merge with OpenBSD - only the Makefiles vary.

We can now survive a compile with
  -Wall -Wbad-function-cast -Wcast-align -Wcast-qual
  -Winline -Wmissing-declarations -Wmissing-prototypes
  -Wnested-externs -Wpointer-arith -Wredundant-decls
  -Wshadow -Wstrict-prototypes -Wwrite-strings -Wchar-subscripts
(although the Makefile just contains -Wall).
1997-11-22 03:37:54 +00:00

93 lines
1.3 KiB
C

/*
* $Id: defs.c,v 1.4 1997/11/18 00:19:30 brian Exp $
*/
#include <sys/param.h>
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "defs.h"
#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
#include "vars.h"
int mode = MODE_INTER;
int BGFiledes[2] = { -1, -1 };
int modem = -1;
int tun_in = -1;
int tun_out = -1;
int netfd = -1;
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;
}
void
randinit()
{
#ifdef __FreeBSD__
static int initdone;
if (!initdone) {
initdone = 1;
srandomdev();
}
#else
srandom(time(NULL)^getpid());
#endif
}
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;
}
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");
}
}