Add veth (#4312), thanks Raphael
authorFlorian Fainelli <florian@openwrt.org>
Wed, 10 Dec 2008 01:20:55 +0000 (01:20 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Wed, 10 Dec 2008 01:20:55 +0000 (01:20 +0000)
SVN-Revision: 13576

net/veth/Makefile [new file with mode: 0644]
net/veth/patches/100-veth-makefile-cflags.patch [new file with mode: 0644]
net/veth/patches/200-drop-multicast.patch [new file with mode: 0644]

diff --git a/net/veth/Makefile b/net/veth/Makefile
new file mode 100644 (file)
index 0000000..5cd7a9a
--- /dev/null
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: $
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=veth
+PKG_VERSION:=1.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.geocities.com/nestorjpg/veth/
+PKG_MD5SUM:=11536388d9c76552a4b736638a458361
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/veth
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=+kmod-tun
+  TITLE:=Virtual Ethernet Device for Linux
+  URL:=http://www.geocities.com/nestorjpg/veth/
+endef
+
+define Package/veth/description
+       VETH is a daemon that virtualizes a ethernet card in Linux. 
+       The virtualization is done via Universal TUN/TAP Driver.
+endef
+
+define Build/Compile   
+       $(MAKE) -C $(PKG_BUILD_DIR)/veth \
+               CC="$(TARGET_CC)" \
+               CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
+               LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/veth/install
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/veth/vethd $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,veth))
diff --git a/net/veth/patches/100-veth-makefile-cflags.patch b/net/veth/patches/100-veth-makefile-cflags.patch
new file mode 100644 (file)
index 0000000..c9a1d74
--- /dev/null
@@ -0,0 +1,14 @@
+Index: veth-1.0/veth/Makefile
+===================================================================
+--- veth-1.0.orig/veth/Makefile        2008-10-29 16:11:33.000000000 +0100
++++ veth-1.0/veth/Makefile     2008-10-31 18:01:33.000000000 +0100
+@@ -4,8 +4,7 @@
+       rm -f vethd
+ vethd: vethd.c
+-      $(CC) -O6 -Wall -pedantic -o vethd vethd.c
+-      strip vethd
++      $(CC) $(CFLAGS) -o vethd vethd.c
+ install: all
+       install -s -m 750 ./vethd $(INSTALL_DIR)
diff --git a/net/veth/patches/200-drop-multicast.patch b/net/veth/patches/200-drop-multicast.patch
new file mode 100644 (file)
index 0000000..438b0d3
--- /dev/null
@@ -0,0 +1,32 @@
+diff -pNur veth-1.0/veth/vethd.c veth-1.0/veth/vethd.c
+--- veth-1.0/veth/vethd.c      2008-11-14 10:59:50.000000000 +0100
++++ veth-1.0/veth/vethd.c      2008-11-24 11:24:45.000000000 +0100
+@@ -29,6 +29,7 @@
+ #include <linux/if_ether.h>
+ #include <linux/if_packet.h>
+ #include <linux/if_tun.h>
++#include <net/ethernet.h>
+ #define max(a,b) ((a)>(b) ? (a):(b))
+@@ -223,6 +224,7 @@ int main(int argc, char **argv)
+       int vfd, nfd, leidos, opc, foreground = 0;
+       fd_set fds;
++      struct ether_header const* const ether_hdr = (struct ether_header const *)buffer;
+       set_locale();
+       show_copyright();
+@@ -356,7 +358,11 @@ int main(int argc, char **argv)
+                               perror("Error reading from ethernet interface");
+                               return 2;
+                       }
+-                      write(vfd, buffer, leidos);
++                      /* drop multicast and ppp session */
++                      if (!(ether_hdr->ether_dhost[0] == 0x01)
++                         && (ether_hdr->ether_type != htons(ETH_P_PPP_SES))) {
++                              write(vfd, buffer, leidos);
++                      }
+               }
+               FD_ZERO(&fds);
+               FD_SET(nfd, &fds);