tun.c revision 31196
1/* 2 * $Id$ 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#include <net/if_var.h> 12#include <net/if_tun.h> 13 14#include <stdio.h> 15#include <string.h> 16#include <sys/ioctl.h> 17#include <sys/errno.h> 18 19#include "hdlc.h" 20#include "defs.h" 21#include "loadalias.h" 22#include "command.h" 23#include "vars.h" 24#include "log.h" 25#include "tun.h" 26 27void 28tun_configure(int mtu, int speed) 29{ 30 struct tuninfo info; 31 32 info.type = 23; 33 info.mtu = mtu; 34 if (VarPrefMTU != 0 && VarPrefMTU < mtu) 35 info.mtu = VarPrefMTU; 36 info.baudrate = speed; 37#ifdef __OpenBSD__ 38 info.flags = IFF_UP|IFF_POINTOPOINT; 39#endif 40 if (ioctl(tun_out, TUNSIFINFO, &info) < 0) 41 LogPrintf(LogERROR, "tun_configure: ioctl(TUNSIFINFO): %s\n", 42 strerror(errno)); 43} 44