socsvn commit: r289057 - soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve
iateaca at FreeBSD.org
iateaca at FreeBSD.org
Sat Aug 1 11:32:00 UTC 2015
Author: iateaca
Date: Sat Aug 1 11:31:59 2015
New Revision: 289057
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289057
Log:
copy the ether_crc32_be function from the net kernel module in the FreeBSD tree sources into my ne2000_ether_crc32_be
Modified:
soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c
Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c
==============================================================================
--- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sat Aug 1 10:40:17 2015 (r289056)
+++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sat Aug 1 11:31:59 2015 (r289057)
@@ -150,6 +150,9 @@
static int
ne2000_ether_frame_is_valid(struct pci_ne2000_softc *sc);
+static uint32_t
+ne2000_ether_crc32_be(const uint8_t *buf, size_t len);
+
static int
ne2000_parse_input(char *opts, char *tap_name, uint8_t *mac);
@@ -449,6 +452,32 @@
return 0;
}
+/*
+ * This function is a copy of the ether_crc32_be function from the net kernel
+ * module in the FreeBSD tree sources
+ */
+static uint32_t
+ne2000_ether_crc32_be(const uint8_t *buf, size_t len)
+{
+ size_t i;
+ uint32_t crc, carry;
+ int bit;
+ uint8_t data;
+
+ crc = 0xffffffff; /* initial value */
+
+ for (i = 0; i < len; i++) {
+ for (data = *buf++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
+ crc <<= 1;
+ if (carry)
+ crc = (crc ^ ETHER_CRC_POLY_BE) | carry;
+ }
+ }
+
+ return (crc);
+}
+
static int
ne2000_parse_input(char *opts, char *tap_name, uint8_t *mac)
{
More information about the svn-soc-all
mailing list