1997-11-17 00:42:41 +00:00
|
|
|
/*
|
1997-11-22 03:37:54 +00:00
|
|
|
* $Id: tun.c,v 1.2 1997/11/17 00:42:41 brian Exp $
|
1997-11-17 00:42:41 +00:00
|
|
|
*/
|
|
|
|
|
1997-11-16 22:15:11 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <net/if.h>
|
1997-11-22 03:37:54 +00:00
|
|
|
#ifdef __FreeBSD__
|
1997-11-16 22:15:11 +00:00
|
|
|
#include <net/if_var.h>
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif
|
1997-11-16 22:15:11 +00:00
|
|
|
#include <net/if_tun.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
#include "command.h"
|
|
|
|
#include "mbuf.h"
|
|
|
|
#include "log.h"
|
1997-11-16 22:15:11 +00:00
|
|
|
#include "hdlc.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "loadalias.h"
|
|
|
|
#include "vars.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));
|
|
|
|
}
|