summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/defs.c
blob: fed64e91005258787658ee4b6e4d7c4f0c7b3d47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * $Id: defs.c,v 1.2 1997/11/11 22:58:10 brian Exp $
 */

#include <sys/param.h>
#include <netinet/in.h>

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "defs.h"
#include "mbuf.h"
#include "log.h"
#include "loadalias.h"
#include "command.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()
{
  static int initdone;

  if (!initdone) {
    initdone = 1;
    srandomdev();
  }
}


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;
}
OpenPOWER on IntegriCloud