Index: uspace/lib/nic/Makefile
===================================================================
--- uspace/lib/nic/Makefile	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/Makefile	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -29,6 +29,7 @@
 USPACE_PREFIX = ../..
 LIBRARY = libnic
-LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a
-EXTRA_CFLAGS += -DLIBNIC_INTERNAL -Iinclude -I$(LIBDRV_PREFIX)/include -I$(LIBNET_PREFIX)/include
+#LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a
+EXTRA_CFLAGS += -DLIBNIC_INTERNAL -Iinclude -I$(LIBDRV_PREFIX)/include
+# -I$(LIBNET_PREFIX)/include
 
 SOURCES = \
Index: uspace/lib/nic/include/nic_driver.h
===================================================================
--- uspace/lib/nic/include/nic_driver.h	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/include/nic_driver.h	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -44,5 +44,5 @@
 
 #include <fibril_synch.h>
-#include <net/device.h>
+#include <nic/nic.h>
 #include <async.h>
 
Index: uspace/lib/nic/include/nic_ev.h
===================================================================
--- uspace/lib/nic/include/nic_ev.h	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/include/nic_ev.h	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -40,6 +40,5 @@
 
 #include <async.h>
-/* XXX for nic_device_id_t and nic_address_t */
-#include <net/device.h>
+#include <nic/nic.h>
 #include <sys/types.h>
 
Index: uspace/lib/nic/include/nic_impl.h
===================================================================
--- uspace/lib/nic/include/nic_impl.h	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/include/nic_impl.h	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -40,7 +40,6 @@
 
 #include <assert.h>
-#include <net/device.h>
+#include <nic/nic.h>
 #include <ddf/driver.h>
-#include <nil_remote.h>
 
 /* Inclusion of this file is not prohibited, because drivers could want to
Index: uspace/lib/nic/include/nic_rx_control.h
===================================================================
--- uspace/lib/nic/include/nic_rx_control.h	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/include/nic_rx_control.h	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -45,5 +45,5 @@
 #include <adt/hash_table.h>
 #include <fibril_synch.h>
-#include <net/device.h>
+#include <nic/nic.h>
 
 #include "nic_addr_db.h"
Index: uspace/lib/nic/include/nic_wol_virtues.h
===================================================================
--- uspace/lib/nic/include/nic_wol_virtues.h	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/include/nic_wol_virtues.h	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -43,5 +43,5 @@
 #endif
 
-#include <net/device.h>
+#include <nic/nic.h>
 #include <adt/hash_table.h>
 #include "nic.h"
Index: uspace/lib/nic/src/nic_ev.c
===================================================================
--- uspace/lib/nic/src/nic_ev.c	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/src/nic_ev.c	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -38,4 +38,5 @@
 #include <async.h>
 #include <device/nic.h>
+#include <errno.h>
 #include "nic_ev.h"
 
Index: uspace/lib/nic/src/nic_impl.c
===================================================================
--- uspace/lib/nic/src/nic_impl.c	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/src/nic_impl.c	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -36,4 +36,5 @@
  */
 
+#include <errno.h>
 #include <str_error.h>
 #include <ipc/services.h>
Index: uspace/lib/nic/src/nic_rx_control.c
===================================================================
--- uspace/lib/nic/src/nic_rx_control.c	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/src/nic_rx_control.c	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -40,7 +40,6 @@
 #include <bool.h>
 #include <errno.h>
-#include <net/device.h>
-#include <net_checksum.h>
-#include <packet_client.h>
+#include <mem.h>
+#include <nic/nic.h>
 #include "nic_rx_control.h"
 
@@ -488,4 +487,43 @@
 }
 
+/** Polynomial used in multicast address hashing */
+#define CRC_MCAST_POLYNOMIAL  0x04c11db6
+
+/** Compute the standard hash from MAC
+ *
+ * Hashing MAC into 64 possible values and using the value as index to
+ * 64bit number.
+ *
+ * The code is copied from qemu-0.13's implementation of ne2000 and rt8139
+ * drivers, but according to documentation there it originates in FreeBSD.
+ *
+ * @param[in] addr The 6-byte MAC address to be hashed
+ *
+ * @return 64-bit number with only single bit set to 1
+ *
+ */
+static uint64_t multicast_hash(const uint8_t addr[6])
+{
+	uint32_t crc;
+    int carry, i, j;
+    uint8_t b;
+
+    crc = 0xffffffff;
+    for (i = 0; i < 6; i++) {
+        b = addr[i];
+        for (j = 0; j < 8; j++) {
+            carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
+            crc <<= 1;
+            b >>= 1;
+            if (carry)
+                crc = ((crc ^ CRC_MCAST_POLYNOMIAL) | carry);
+        }
+    }
+	
+    uint64_t one64 = 1;
+    return one64 << (crc >> 26);
+}
+
+
 /**
  * Computes hash for the address list based on standard multicast address
Index: uspace/lib/nic/src/nic_wol_virtues.c
===================================================================
--- uspace/lib/nic/src/nic_wol_virtues.c	(revision 8d7ec69d8e6ebbc57c70b70b6ed09ed1b8ceba0c)
+++ uspace/lib/nic/src/nic_wol_virtues.c	(revision cf9cb36f0ca62c70ee2bfb4b1c4cce6ed794d7bb)
@@ -38,4 +38,5 @@
 #include "nic_wol_virtues.h"
 #include <assert.h>
+#include <errno.h>
 
 #define NIC_WV_HASH_COUNT 32
