From owner-FreeBSD-tech-jp@jp.FreeBSD.org Sun Mar  2 18:22:02 2003
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id h229M2S23146;
	Sun, 2 Mar 2003 18:22:02 +0900 (JST)
	(envelope-from owner-FreeBSD-tech-jp@jp.FreeBSD.org)
Received: from mps7.plala.or.jp (c150240.ap.plala.or.jp [210.150.150.240])
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) with ESMTP/inet id h229M2i23139
	for <FreeBSD-tech-jp@jp.FreeBSD.org>; Sun, 2 Mar 2003 18:22:02 +0900 (JST)
	(envelope-from s-hrgsh@lapis.plala.or.jp)
Received: from sv ([218.47.134.217]) by mps7.plala.or.jp with SMTP
          id <20030302092158.CRLJ22122.mps7.plala.or.jp@sv>
          for <FreeBSD-tech-jp@jp.FreeBSD.org>;
          Sun, 2 Mar 2003 18:21:58 +0900
From: Seishi Hiragushi <s-hrgsh@lapis.plala.or.jp>
To: FreeBSD-tech-jp@jp.FreeBSD.org
Message-Id: <20030302182158.2d0cba59.s-hrgsh@lapis.plala.or.jp>
In-Reply-To: <20030301003539.2749814e.s-hrgsh@lapis.plala.or.jp>
References: <20030204223708.STBL21276.pop03.dreamnet.ne.jp@chino.localhost>
	<20030301003539.2749814e.s-hrgsh@lapis.plala.or.jp>
X-Mailer: Sylpheed version 0.8.10 (GTK+ 1.2.10; i386-portbld-freebsd4.7)
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit
Reply-To: FreeBSD-tech-jp@jp.FreeBSD.org
Precedence: list
Date: Sun, 2 Mar 2003 18:21:58 +0900
X-Sequence: FreeBSD-tech-jp 3331
Subject: [FreeBSD-tech-jp 3331] Re: CRC32
Errors-To: owner-FreeBSD-tech-jp@jp.FreeBSD.org
Sender: owner-FreeBSD-tech-jp@jp.FreeBSD.org
X-Originator: s-hrgsh@lapis.plala.or.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+030107

$BJ?6{$G$9!#(B

> > $B$3$l$r:8Aw$j$K$D$$$F$b!"(B4bit$BC10L$G$N%F!<%V%k;2>H$G7W;;$9$k$3$H$O$G$-$J$$(B
> > $B$G$7$g$&$+!)$H$$$&$N$,:#2s$N<ALd$K$J$j$^$9!#(B
> 
> $B0J2<$N$h$&$J%3!<%I$G7W;;$G$-$k$h$&$G$9!#(B
> bit$BNs$N=g$r5U$K$7$J$$$H$$$1$J$$$N$,?I$$$H$3$m!#(B

$B$5$i$K@0M}$7$F$_$^$7$?!#(B

u_int32_t
ether_crc32_be(const u_int8_t *buf, size_t len)
{
  u_int32_t	crc = ~0;
  int i;

  static unsigned char cnv[]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};

  static const unsigned long     crctab[] = {
  0x00000000UL, 0x04c11db7UL, 0x09823b6eUL, 0x0d4326d9UL,
  0x130476dcUL, 0x17c56b6bUL, 0x1a864db2UL, 0x1e475005UL,
  0x2608edb8UL, 0x22c9f00fUL, 0x2f8ad6d6UL, 0x2b4bcb61UL,
  0x350c9b64UL, 0x31cd86d3UL, 0x3c8ea00aUL, 0x384fbdbdUL,
  };

  for (i = 0; i < len; ++i) {
        crc = (crc << 4) ^ crctab[(crc >> 28) ^ cnv[*buf & 0xF]];
        crc = (crc << 4) ^ crctab[(crc >> 28) ^ cnv[*buf++ >>4]];
  }
  return crc;
}

