Needed for Hurd 0.3

2008-07-29 Zheng Da <zhengda1936@gmail.com>

	* ethernet.c: Open the virtual network device.
	(ether_filter): Use the bpf filter.
	(ethernet_open): Change the way of opening the network device.

diff -urN -x '*.[od]' -x '*Server.c' -x '*_S.h' -x '*.prof_d' -x '*~' pfinet.old/ethernet.c pfinet1/ethernet.c
--- pfinet.old/ethernet.c	2007-10-09 10:01:34.120000000 +0200
+++ pfinet1/ethernet.c	2008-08-16 18:09:08.000000000 +0200
@@ -26,11 +26,14 @@
 #include <device/net_status.h>
 #include <netinet/in.h>
 #include <string.h>
+#define _HACK_ERRNO_H
+#include <errno.h>
 #include <error.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/if_arp.h>
+#include <device/bpf.h>
 
 
 struct port_class *etherreadclass;
@@ -68,15 +71,15 @@
 {
 }
 
-static short ether_filter[] =
+/* The BPF instruction allows IP and ARP packets */
+static struct bpf_insn ether_filter[] =
 {
-#ifdef NETF_IN
-  /* We have to tell the packet filtering code that we're interested in
-     incoming packets.  */
-  NETF_IN, /* Header.  */
-#endif
-  NETF_PUSHLIT | NETF_NOP,
-  1
+    {NETF_IN|NETF_BPF, /* Header. */ 0, 0, 0},
+    {40, 0, 0, 12},
+    {21, 1, 0, 2054},
+    {21, 0, 1, 2048},
+    {6, 0, 0, 1500},
+    {6, 0, 0, 0}
 };
 static int ether_filter_len = sizeof (ether_filter) / sizeof (short);
 
@@ -166,11 +169,12 @@
 
   mach_port_set_qlimit (mach_task_self (), edev->readptname, MACH_PORT_QLIMIT_MAX);
 
-  err = get_privileged_ports (0, &master_device);
-  if (err)
-    error (2, err, "cannot get device master port");
+  /* The device name here is the path of a device file.  */
+  master_device = file_name_lookup (dev->name, 0, 0);
+  if (master_device == MACH_PORT_NULL)
+    error (2, errno, "file_name_lookup %s", dev->name);
 
-  err = device_open (master_device, D_WRITE | D_READ, dev->name, &edev->ether_port);
+  err = device_open (master_device, D_WRITE | D_READ, "eth", &edev->ether_port);
   mach_port_deallocate (mach_task_self (), master_device);
   if (err)
     error (2, err, "%s", dev->name);

