tun.c revision 31343
1/*
2 * $Id: tun.c,v 1.2 1997/11/17 00:42:41 brian Exp $
3 */
4
5#include <sys/param.h>
6#include <sys/time.h>
7#include <sys/select.h>
8#include <sys/socket.h>
9#include <netinet/in.h>
10#include <net/if.h>
11#ifdef __FreeBSD__
12#include <net/if_var.h>
13#endif
14#include <net/if_tun.h>
15
16#include <stdio.h>
17#include <string.h>
18#include <sys/ioctl.h>
19#include <sys/errno.h>
20
21#include "command.h"
22#include "mbuf.h"
23#include "log.h"
24#include "hdlc.h"
25#include "defs.h"
26#include "loadalias.h"
27#include "vars.h"
28#include "tun.h"
29
30void
31tun_configure(int mtu, int speed)
32{
33  struct tuninfo info;
34
35  info.type = 23;
36  info.mtu = mtu;
37  if (VarPrefMTU != 0 && VarPrefMTU < mtu)
38    info.mtu = VarPrefMTU;
39  info.baudrate = speed;
40#ifdef __OpenBSD__
41  info.flags = IFF_UP|IFF_POINTOPOINT;
42#endif
43  if (ioctl(tun_out, TUNSIFINFO, &info) < 0)
44    LogPrintf(LogERROR, "tun_configure: ioctl(TUNSIFINFO): %s\n",
45	      strerror(errno));
46}
47