summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/tun.c
blob: bee63cb6671584d9fe45c183de78e199ba5e502e (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
/*
 * $Id$
 */

#include <sys/param.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_tun.h>

#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/errno.h>

#include "hdlc.h"
#include "defs.h"
#include "loadalias.h"
#include "command.h"
#include "vars.h"
#include "log.h"
#include "tun.h"

void
tun_configure(int mtu, int speed)
{
  struct tuninfo info;

  info.type = 23;
  info.mtu = mtu;
  if (VarPrefMTU != 0 && VarPrefMTU < mtu)
    info.mtu = VarPrefMTU;
  info.baudrate = speed;
#ifdef __OpenBSD__                                           
  info.flags = IFF_UP|IFF_POINTOPOINT;                             
#endif
  if (ioctl(tun_out, TUNSIFINFO, &info) < 0)
    LogPrintf(LogERROR, "tun_configure: ioctl(TUNSIFINFO): %s\n",
	      strerror(errno));
}
OpenPOWER on IntegriCloud