亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tun.c

?? 一個開源的VPN原碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* *  OpenVPN -- An application to securely tunnel IP networks *             over a single UDP port, with support for TLS-based *             session authentication and key exchange, *             packet encryption, packet authentication, and *             packet compression. * *  Copyright (C) 2002 James Yonan <jim@yonan.net> * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program (see the file COPYING included with this *  distribution); if not, write to the Free Software Foundation, Inc., *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *//* * This file is based on the TUN/TAP driver interface routines * from VTun by Maxim Krasnyansky <max_mk@yahoo.com>. */#include "config.h"#include "syshead.h"#include "tun.h"#include "fdmisc.h"#include "error.h"#include "buffer.h"#include "common.h"#include "misc.h"#include "memdbg.h"static boolis_dev_type (const char *dev, const char *dev_type, const char *match_type){  ASSERT (dev);  ASSERT (match_type);  if (dev_type)    return !strcmp (dev_type, match_type);  else    return !strncmp (dev, match_type, strlen (match_type));}const char *dev_type_string(const char *dev, const char *dev_type){  if (is_dev_type (dev, dev_type, "tun"))    return "tun";  else if (is_dev_type (dev, dev_type, "tap"))    return "tap";  else if (is_dev_type (dev, dev_type, "null"))    return "null";  else    return "[unknown-dev-type]";}const char *dev_component_in_dev_node (const char *dev_node){  const char *ret;  const int dirsep = '/';  if (dev_node)    {      ret = rindex (dev_node, dirsep);      if (ret && *ret)	++ret;      else	ret = dev_node;      if (*ret)	return ret;    }  return NULL;}/* * Called by the open_tun function of OSes to check if we * explicitly support IPv6. * * In this context, explicit means that the OS expects us to * do something special to the tun socket in order to support * IPv6, i.e. it is not transparent. * * ipv6_explicitly_supported should be set to false if we don't * have any explicit IPv6 code in the tun device handler. * * If ipv6_explicitly_supported is true, then we have explicit * OS-specific tun dev code for handling IPv6.  If so, tt->ipv6 * is set according to the --tun-ipv6 command line option. */static voidipv6_support (bool ipv6, bool ipv6_explicitly_supported, struct tuntap* tt){  tt->ipv6 = false;  if (ipv6_explicitly_supported)    tt->ipv6 = ipv6;  else if (ipv6)    msg (M_WARN, "NOTE: explicit support for IPv6 tun devices is not provided for this OS");}/* do ifconfig */voiddo_ifconfig (const char *dev, const char *dev_type,	     const char *ifconfig_local, const char *ifconfig_remote,	     int tun_mtu){  if (ifconfig_local && ifconfig_remote)    {      char command_line[256];      if (!is_dev_type (dev, dev_type, "tun"))	msg (M_FATAL, "%s is not a tun device.  The --ifconfig option works only for tun devices.  You should use an --up script to ifconfig a tap device.", dev);#if defined(TARGET_LINUX)      snprintf (command_line, sizeof (command_line),		IFCONFIG_PATH " %s %s pointopoint %s mtu %d",		dev,		ifconfig_local,		ifconfig_remote,		tun_mtu		);      msg (M_INFO, "%s", command_line);      system_check (command_line, "Linux ifconfig failed", true);#elif defined(TARGET_SOLARIS)      /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */      snprintf (command_line, sizeof (command_line),		IFCONFIG_PATH " %s %s %s mtu %d netmask 255.255.255.255 up",		dev,		ifconfig_local,		ifconfig_remote,		tun_mtu		);      msg (M_INFO, "%s", command_line);      system_check (command_line, "Solaris ifconfig failed", true);#elif defined(TARGET_OPENBSD)      /*       * OpenBSD tun devices appear to be persistent by default.  It seems in order       * to make this work correctly, we need to delete the previous instance       * (if it exists), and re-ifconfig.  Let me know if you know a better way.       */      snprintf (command_line, sizeof (command_line),		IFCONFIG_PATH " %s delete",		dev);      msg (M_INFO, "%s", command_line);      system_check (command_line, NULL, false);      msg (M_INFO, "NOTE: Tried to delete pre-existing tun instance -- No Problem if failure");      /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */      snprintf (command_line, sizeof (command_line),		IFCONFIG_PATH " %s %s %s mtu %d netmask 255.255.255.255 up",		dev,		ifconfig_local,		ifconfig_remote,		tun_mtu		);      msg (M_INFO, "%s", command_line);      system_check (command_line, "OpenBSD ifconfig failed", true);#elif defined(TARGET_NETBSD)      snprintf (command_line, sizeof (command_line),	        IFCONFIG_PATH " %s %s %s mtu %d netmask 255.255.255.255 up",	        dev,		ifconfig_local,                ifconfig_remote,                tun_mtu                );      msg (M_INFO, "%s", command_line);      system_check (command_line, "NetBSD ifconfig failed", true);#elif defined(TARGET_DARWIN)      /*       * Darwin seems to exibit similar behaviour to OpenBSD...       */      snprintf (command_line, sizeof (command_line),		IFCONFIG_PATH " %s delete",		dev);      msg (M_INFO, "%s", command_line);      system_check (command_line, NULL, false);      msg (M_INFO, "NOTE: Tried to delete pre-existing tun instance -- No Problem if failure");      /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */      snprintf (command_line, sizeof (command_line),		IFCONFIG_PATH " %s %s %s mtu %d netmask 255.255.255.255 up",		dev,		ifconfig_local,		ifconfig_remote,		tun_mtu		);      msg (M_INFO, "%s", command_line);      system_check (command_line, "Darwin ifconfig failed", true);#elif defined(TARGET_FREEBSD)      /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */      snprintf (command_line, sizeof (command_line),		IFCONFIG_PATH " %s %s %s mtu %d netmask 255.255.255.255 up",		dev,		ifconfig_local,		ifconfig_remote,		tun_mtu		);      msg (M_INFO, "%s", command_line);      system_check (command_line, "FreeBSD ifconfig failed", true);#else      msg (M_FATAL, "Sorry, but I don't know how to do 'ifconfig' commands on this operating system.  You should ifconfig your tun/tap device manually or use an --up script.");#endif    }}voidclear_tuntap (struct tuntap *tuntap){  tuntap->fd = -1;#ifdef TARGET_SOLARIS  tuntap->ip_fd = -1;#endif  tuntap->ipv6 = false;  CLEAR (tuntap->actual);}static voidopen_null (struct tuntap *tt){  clear_tuntap (tt);  strncpynt (tt->actual, "null", sizeof (tt->actual));}static voidopen_tun_generic (const char *dev, const char *dev_node,		  bool ipv6, bool ipv6_explicitly_supported,		  struct tuntap *tt){  char tunname[64];  clear_tuntap (tt);  ipv6_support (ipv6, ipv6_explicitly_supported, tt);  if (!strcmp(dev, "null"))    {      open_null (tt);    }  else    {      if (dev_node)	snprintf (tunname, sizeof (tunname), "%s", dev_node);      else	snprintf (tunname, sizeof (tunname), "/dev/%s", dev);      if ((tt->fd = open (tunname, O_RDWR)) < 0)	msg (M_ERR, "Cannot open tun/tap dev %s", tunname);      set_nonblock (tt->fd);      msg (M_INFO, "tun/tap device %s opened", tunname);      strncpynt (tt->actual, dev, sizeof (tt->actual));    }}static voidclose_tun_generic (struct tuntap *tt){  if (tt->fd >= 0)    close (tt->fd);  clear_tuntap (tt);}#if defined(TARGET_LINUX)#ifdef HAVE_LINUX_IF_TUN_H	/* New driver support */#if defined(HAVE_NETINET_IF_ETHER_H) && defined(HAVE_NETINET_IP_H) && defined(ETH_P_IPV6)#define LINUX_IPV6 1#else#define LINUX_IPV6 0#endifvoidopen_tun (const char *dev, const char *dev_type, const char *dev_node, bool ipv6,	  struct tuntap *tt){  struct ifreq ifr;  clear_tuntap (tt);  ipv6_support (ipv6, LINUX_IPV6, tt);  if (!strcmp(dev, "null"))    {      open_null (tt);    }  else    {      if (!dev_node)	dev_node = "/dev/net/tun";      if ((tt->fd = open (dev_node, O_RDWR)) < 0)	msg (M_ERR, "Cannot open tun/tap dev %s", dev_node);      CLEAR (ifr);      if (!tt->ipv6)	ifr.ifr_flags = IFF_NO_PI;      if (is_dev_type (dev, dev_type, "tun"))	{	  ifr.ifr_flags |= IFF_TUN;	}      else if (is_dev_type (dev, dev_type, "tap"))	{	  ifr.ifr_flags |= IFF_TAP;	}      else	{	  msg (M_FATAL, "I don't recognize device %s as a tun or tap device",	       dev);	}      if (strlen (dev) > 3)		/* unit number specified? */	strncpynt (ifr.ifr_name, dev, IFNAMSIZ);      if (ioctl (tt->fd, TUNSETIFF, (void *) &ifr) < 0)	msg (M_ERR, "Cannot ioctl TUNSETIFF %s", dev);      set_nonblock (tt->fd);      msg (M_INFO, "tun/tap device %s opened", ifr.ifr_name);      strncpynt (tt->actual, ifr.ifr_name, sizeof (tt->actual));    }}#ifdef TUNSETPERSISTvoid

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品一区二区不卡| 一区二区三区在线免费视频| 日日夜夜精品视频免费| 国产麻豆日韩欧美久久| 欧美午夜一区二区| 亚洲二区在线观看| 91精品在线免费观看| 精久久久久久久久久久| 久久久影视传媒| 日本精品裸体写真集在线观看 | 一区二区三区中文在线观看| 欧美亚洲一区二区在线| 麻豆精品一区二区av白丝在线| 久久精品水蜜桃av综合天堂| 91美女片黄在线| 偷拍自拍另类欧美| 久久久影院官网| 色av综合在线| 九九热在线视频观看这里只有精品| 中文字幕乱码日本亚洲一区二区 | 国产一区在线观看视频| 一区在线观看视频| 51午夜精品国产| 国产不卡在线一区| 亚洲成人动漫一区| 国产清纯白嫩初高生在线观看91 | 欧美伦理电影网| 久久超碰97中文字幕| 中文字幕在线视频一区| 日韩免费电影一区| 一本色道久久综合亚洲精品按摩| 免费成人av在线| 亚洲欧美aⅴ...| 久久午夜色播影院免费高清 | 91精品国产一区二区三区香蕉| 国产成人av影院| 午夜成人免费电影| 亚洲欧洲另类国产综合| 精品国产不卡一区二区三区| 一本一道久久a久久精品| 久久不见久久见免费视频1| 一区二区三区四区在线| 国产精品视频在线看| 成人美女在线视频| 视频一区欧美精品| 国产精品色哟哟| 欧美一区二区黄色| 欧美丝袜丝交足nylons| 成人黄色免费短视频| 激情av综合网| 久久国产婷婷国产香蕉| 亚洲福利视频一区二区| 亚洲人成精品久久久久| 国产精品女主播av| 久久蜜臀精品av| 欧美精品一区二区三区一线天视频 | 日本精品一级二级| 99久久综合狠狠综合久久| 国产乱人伦偷精品视频不卡 | 国产成人午夜高潮毛片| 日本不卡中文字幕| 亚洲福利视频导航| 国产成人亚洲精品狼色在线| 蜜桃视频免费观看一区| 无码av免费一区二区三区试看| 亚洲精品欧美二区三区中文字幕| 国产精品污污网站在线观看| 国产人成一区二区三区影院| 久久综合色婷婷| 国产亚洲精品超碰| 国产拍揄自揄精品视频麻豆| 欧美激情综合五月色丁香| 国产日韩一级二级三级| 欧美激情一区在线| 国产精品丝袜一区| 中文字幕佐山爱一区二区免费| 国产精品成人免费在线| 亚洲色图一区二区| 亚洲精品乱码久久久久久黑人| 亚洲欧美色综合| 一区二区三区在线高清| 亚洲va国产va欧美va观看| 亚洲成人av福利| 男女性色大片免费观看一区二区| 日韩精品一级二级| 精品亚洲成a人| 国产精品99久久久久久宅男| 丁香桃色午夜亚洲一区二区三区| 国产成人综合网| 97se狠狠狠综合亚洲狠狠| 91国偷自产一区二区三区成为亚洲经典 | 中文字幕不卡在线观看| 亚洲欧美怡红院| 亚洲国产精品久久久久秋霞影院 | 久久日一线二线三线suv| 日本一区二区成人在线| 亚洲三级久久久| 天天色综合天天| 国产精品99久| 欧美中文字幕久久| 精品国内片67194| 自拍偷自拍亚洲精品播放| 亚洲成av人片一区二区梦乃 | 国产精品毛片大码女人| 亚洲黄网站在线观看| 蜜桃av一区二区| 成人手机在线视频| 精品视频一区二区不卡| 久久久精品中文字幕麻豆发布| 亚洲精品国产精品乱码不99| 免费久久99精品国产| 成人av中文字幕| 欧美顶级少妇做爰| 国产精品沙发午睡系列990531| 亚洲成av人片| av电影在线观看完整版一区二区| 欧美日韩高清一区二区| 国产精品午夜久久| 视频一区二区三区入口| 成人黄色小视频在线观看| 欧美人伦禁忌dvd放荡欲情| 日本一区二区三区在线不卡| 午夜欧美在线一二页| 成人免费高清在线| 日韩午夜精品视频| 亚洲精品乱码久久久久久久久| 黄页视频在线91| 91久久精品一区二区三| 日本一区二区三区视频视频| 天天色综合天天| 99久久精品国产麻豆演员表| 精品久久久久一区| 亚洲第一av色| 99久久精品情趣| 久久久蜜桃精品| 青青草国产成人av片免费| 日本精品免费观看高清观看| 日本一区二区三区视频视频| 精油按摩中文字幕久久| 欧美日韩高清在线| 亚洲一区二区在线观看视频 | 久久电影网站中文字幕| 欧美日韩国产综合久久| 亚洲色图制服诱惑 | 日韩av电影天堂| 欧美亚洲另类激情小说| 亚洲少妇最新在线视频| 成人福利视频在线看| 久久综合给合久久狠狠狠97色69| 秋霞电影一区二区| 这里是久久伊人| 日韩精品一级二级| 欧美美女视频在线观看| 亚洲夂夂婷婷色拍ww47 | 日韩二区三区四区| 欧美亚洲尤物久久| 亚洲一区在线视频| 欧美图区在线视频| 午夜电影久久久| 7777精品久久久大香线蕉| 视频一区在线视频| 欧美一区二区三区系列电影| 亚洲大片精品永久免费| 欧美老年两性高潮| 亚洲第一综合色| 538在线一区二区精品国产| 视频一区二区中文字幕| 日韩欧美区一区二| 国精产品一区一区三区mba桃花| 久久伊99综合婷婷久久伊| 国产曰批免费观看久久久| 国产三级精品视频| 成人小视频免费在线观看| 国产精品的网站| 国产精品99久久久| 国产精品福利av| 在线观看视频一区二区| 亚洲国产日产av| 日韩欧美国产wwwww| 国产精品自在欧美一区| 国产精品护士白丝一区av| 色系网站成人免费| 日韩中文欧美在线| 久久久影视传媒| 91麻豆国产香蕉久久精品| 亚洲另类在线一区| 欧美美女直播网站| 久久91精品国产91久久小草| 国产精品午夜电影| 欧美在线一区二区| 美女免费视频一区| 国产精品剧情在线亚洲| 欧美日韩成人综合| 国产精品一卡二卡在线观看| 综合av第一页| 日韩免费成人网| 99re视频精品| 轻轻草成人在线| 国产精品九色蝌蚪自拍| 欧美美女一区二区三区|