11ae349f5Scvs2svn /*- 21ae349f5Scvs2svn * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org> 31ae349f5Scvs2svn * All rights reserved. 41ae349f5Scvs2svn * 51ae349f5Scvs2svn * Redistribution and use in source and binary forms, with or without 61ae349f5Scvs2svn * modification, are permitted provided that the following conditions 71ae349f5Scvs2svn * are met: 81ae349f5Scvs2svn * 1. Redistributions of source code must retain the above copyright 91ae349f5Scvs2svn * notice, this list of conditions and the following disclaimer. 101ae349f5Scvs2svn * 2. Redistributions in binary form must reproduce the above copyright 111ae349f5Scvs2svn * notice, this list of conditions and the following disclaimer in the 121ae349f5Scvs2svn * documentation and/or other materials provided with the distribution. 131ae349f5Scvs2svn * 141ae349f5Scvs2svn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 151ae349f5Scvs2svn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161ae349f5Scvs2svn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171ae349f5Scvs2svn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181ae349f5Scvs2svn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 191ae349f5Scvs2svn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201ae349f5Scvs2svn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211ae349f5Scvs2svn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221ae349f5Scvs2svn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 231ae349f5Scvs2svn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241ae349f5Scvs2svn * SUCH DAMAGE. 251ae349f5Scvs2svn * 261ae349f5Scvs2svn * $Id: tun.c,v 1.5 1998/01/11 17:53:27 brian Exp $ 271ae349f5Scvs2svn */ 281ae349f5Scvs2svn 291ae349f5Scvs2svn #include <sys/param.h> 301ae349f5Scvs2svn #include <sys/time.h> 311ae349f5Scvs2svn #include <sys/socket.h> 321ae349f5Scvs2svn #include <netinet/in.h> 331ae349f5Scvs2svn #include <net/if.h> 341ae349f5Scvs2svn #include <net/if_tun.h> 351ae349f5Scvs2svn 361ae349f5Scvs2svn #include <stdio.h> 371ae349f5Scvs2svn #include <string.h> 381ae349f5Scvs2svn #include <sys/ioctl.h> 391ae349f5Scvs2svn #include <sys/errno.h> 401ae349f5Scvs2svn 411ae349f5Scvs2svn #include "command.h" 421ae349f5Scvs2svn #include "mbuf.h" 431ae349f5Scvs2svn #include "log.h" 441ae349f5Scvs2svn #include "hdlc.h" 451ae349f5Scvs2svn #include "defs.h" 461ae349f5Scvs2svn #include "loadalias.h" 471ae349f5Scvs2svn #include "vars.h" 481ae349f5Scvs2svn #include "tun.h" 491ae349f5Scvs2svn 501ae349f5Scvs2svn void 511ae349f5Scvs2svn tun_configure(int mtu, int speed) 521ae349f5Scvs2svn { 531ae349f5Scvs2svn struct tuninfo info; 541ae349f5Scvs2svn 551ae349f5Scvs2svn info.type = 23; 561ae349f5Scvs2svn info.mtu = mtu; 571ae349f5Scvs2svn if (VarPrefMTU != 0 && VarPrefMTU < mtu) 581ae349f5Scvs2svn info.mtu = VarPrefMTU; 591ae349f5Scvs2svn info.baudrate = speed; 601ae349f5Scvs2svn #ifdef __OpenBSD__ 611ae349f5Scvs2svn info.flags = IFF_UP|IFF_POINTOPOINT; 621ae349f5Scvs2svn #endif 631ae349f5Scvs2svn if (ioctl(tun_out, TUNSIFINFO, &info) < 0) 641ae349f5Scvs2svn LogPrintf(LogERROR, "tun_configure: ioctl(TUNSIFINFO): %s\n", 651ae349f5Scvs2svn strerror(errno)); 661ae349f5Scvs2svn } 67