1c39934eaSBrian Somers /*- 2c39934eaSBrian Somers * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org> 3c39934eaSBrian Somers * All rights reserved. 4c39934eaSBrian Somers * 5c39934eaSBrian Somers * Redistribution and use in source and binary forms, with or without 6c39934eaSBrian Somers * modification, are permitted provided that the following conditions 7c39934eaSBrian Somers * are met: 8c39934eaSBrian Somers * 1. Redistributions of source code must retain the above copyright 9c39934eaSBrian Somers * notice, this list of conditions and the following disclaimer. 10c39934eaSBrian Somers * 2. Redistributions in binary form must reproduce the above copyright 11c39934eaSBrian Somers * notice, this list of conditions and the following disclaimer in the 12c39934eaSBrian Somers * documentation and/or other materials provided with the distribution. 13c39934eaSBrian Somers * 14c39934eaSBrian Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15c39934eaSBrian Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16c39934eaSBrian Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17c39934eaSBrian Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18c39934eaSBrian Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19c39934eaSBrian Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20c39934eaSBrian Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21c39934eaSBrian Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22c39934eaSBrian Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23c39934eaSBrian Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24c39934eaSBrian Somers * SUCH DAMAGE. 25c39934eaSBrian Somers * 268fa6ebe4SBrian Somers * $Id: tun.c,v 1.9 1998/08/09 16:41:01 brian Exp $ 27c7d4711fSBrian Somers */ 28c7d4711fSBrian Somers 292764b86aSBrian Somers #include <sys/types.h> 3010a9be1eSBrian Somers #include <sys/socket.h> /* For IFF_ defines */ 3110a9be1eSBrian Somers #include <net/if.h> /* For IFF_ defines */ 321ae349f5Scvs2svn #include <netinet/in.h> 3344cae95dSBrian Somers #include <net/if_types.h> 346a6b4bbbSBrian Somers #include <net/if_tun.h> 35eaa4df37SBrian Somers #include <netinet/in_systm.h> 36eaa4df37SBrian Somers #include <netinet/ip.h> 371fa665f5SBrian Somers #include <sys/un.h> 386a6b4bbbSBrian Somers 396a6b4bbbSBrian Somers #include <string.h> 406a6b4bbbSBrian Somers #include <sys/ioctl.h> 416a6b4bbbSBrian Somers #include <sys/errno.h> 426a6b4bbbSBrian Somers 43b6e82f33SBrian Somers #include "mbuf.h" 44b6e82f33SBrian Somers #include "log.h" 4563258dccSBrian Somers #include "timer.h" 46879ed6faSBrian Somers #include "lqr.h" 476a6b4bbbSBrian Somers #include "hdlc.h" 486a6b4bbbSBrian Somers #include "defs.h" 496d666775SBrian Somers #include "fsm.h" 505828db6dSBrian Somers #include "throughput.h" 515828db6dSBrian Somers #include "iplist.h" 52eaa4df37SBrian Somers #include "slcompress.h" 535828db6dSBrian Somers #include "ipcp.h" 545ca5389aSBrian Somers #include "filter.h" 552f786681SBrian Somers #include "descriptor.h" 563b0f8d2eSBrian Somers #include "lcp.h" 573b0f8d2eSBrian Somers #include "ccp.h" 583b0f8d2eSBrian Somers #include "link.h" 593b0f8d2eSBrian Somers #include "mp.h" 607a6f8720SBrian Somers #include "bundle.h" 616a6b4bbbSBrian Somers #include "tun.h" 626a6b4bbbSBrian Somers 636a6b4bbbSBrian Somers void 64faefde08SBrian Somers tun_configure(struct bundle *bundle, int mtu) 656a6b4bbbSBrian Somers { 666a6b4bbbSBrian Somers struct tuninfo info; 676a6b4bbbSBrian Somers 688fa6ebe4SBrian Somers memset(&info, '\0', sizeof info); 6944cae95dSBrian Somers info.type = IFT_PPP; 706a6b4bbbSBrian Somers info.mtu = mtu; 718fa6ebe4SBrian Somers info.baudrate = bundle->ifSpeed; 726a6b4bbbSBrian Somers #ifdef __OpenBSD__ 736a6b4bbbSBrian Somers info.flags = IFF_UP|IFF_POINTOPOINT; 746a6b4bbbSBrian Somers #endif 75faefde08SBrian Somers if (ioctl(bundle->dev.fd, TUNSIFINFO, &info) < 0) 76dd7e2610SBrian Somers log_Printf(LogERROR, "tun_configure: ioctl(TUNSIFINFO): %s\n", 776a6b4bbbSBrian Somers strerror(errno)); 786a6b4bbbSBrian Somers } 79