⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ethertap.txt

📁 《嵌入式系统设计与实例开发实验教材二源码》Linux内核移植与编译实验
💻 TXT
字号:
NOTE: Ethertap is now an obsolete facility, and is scheduled      to be removed in the 2.5.x kernel series.  Those writing      applications using ethertap should convert their code to      use the TUN/TAP driver instead, see 'tuntap.txt' in this      directory for more details.  -DaveMEthertap programming mini-HOWTO-------------------------------The ethertap driver was written by Jay Schulist <jschlst@samba.org>,you should contact him for further information. This document was written bybert hubert <bert.hubert@netherlabs.nl>. Updates are welcome.What ethertap can do for you----------------------------Ethertap allows you to easily run your own network stack from userspace.Tunnels can benefit greatly from this. You can also use it to do networkexperiments. The alternative would be to use a raw socket to send data anduse libpcap to receive it. Using ethertap saves you this multiplicity andalso does ARP for you if you want.The more technical blurb:Ethertap provides packet reception and transmission for user space programs.It can be viewed as a simple Ethernet device, which instead of receivingpackets from a network wire, it receives them from user space.Ethertap can be used for anything from AppleTalk to IPX to even buildingbridging tunnels. It also has many other general purpose uses.Configuring your kernel-----------------------Firstly, you need this in Networking Options:	#	# Code maturity level options	#	CONFIG_EXPERIMENTAL=yThen you need Netlink support:	CONFIG_NETLINK=yThis allows the kernel to exchange data with userspace applications. Thereare two ways of doing this, the new way works with netlink sockets and Ihave no experience with that yet. ANK uses it in his excellent iproute2package, see for example rtmon.c. iproute2 can be found onftp://ftp.inr.ac.ru/ip-routing/iproute2*The new way is described, partly in netlink(7), available on http://www.europe.redhat.com/documentation/man-pages/man7/netlink.7.php3There is also a Netlink-HOWTO, available on http://snafu.freedom.org/linux2.2/docs/netlink-HOWTO.htmlSadly I know of no code using ethertap with this new interface.The older way works by opening character special files with major node 36.Enable this with:	CONFIG_NETLINK_DEV=mPlease be advised that this support is going to be dropped somewhere in thefuture!Then finally in the Network Devices section, 	CONFIG_ETHERTAP=mYou can include it directly in the kernel if you want, of course, no needfor modules.Setting it all up-----------------First we need to create the /dev/tap0 device node:	# mknod /dev/tap0 c 36 16	# mknod /dev/tap1 c 36 17	(etc)Include the relevant modules (ethertap.o, netlink_dev.o, perhaps netlink.o),and bring up your tap0 device:	# ifconfig tap0 10.0.0.123 upNow your device is up and running, you can ping it as well. This is whatconfused me to no end, because nothing is connected to our ethertap as yet,how is it that we can ping it?It turns out that the ethertap is just like a regular network interface -even when it's down you can ping it. We need to route stuff to it:	# route add -host 10.0.0.124 gw 10.0.0.123Now we can read /dev/tap0 and when we ping 10.0.0.124 from ourlocalhost, output should appear on the screen.	# cat /dev/tap0	:遃U:9````````````````````````

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -