aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/crc32c.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/crc32c.c')
-rw-r--r--net/sctp/crc32c.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/net/sctp/crc32c.c b/net/sctp/crc32c.c
index 31f05ec8e1d3..59cf7b06d216 100644
--- a/net/sctp/crc32c.c
+++ b/net/sctp/crc32c.c
@@ -1,40 +1,40 @@
1/* SCTP kernel reference Implementation 1/* SCTP kernel reference Implementation
2 * Copyright (c) 1999-2001 Motorola, Inc. 2 * Copyright (c) 1999-2001 Motorola, Inc.
3 * Copyright (c) 2001-2003 International Business Machines, Corp. 3 * Copyright (c) 2001-2003 International Business Machines, Corp.
4 * 4 *
5 * This file is part of the SCTP kernel reference Implementation 5 * This file is part of the SCTP kernel reference Implementation
6 * 6 *
7 * SCTP Checksum functions 7 * SCTP Checksum functions
8 * 8 *
9 * The SCTP reference implementation is free software; 9 * The SCTP reference implementation is free software;
10 * you can redistribute it and/or modify it under the terms of 10 * you can redistribute it and/or modify it under the terms of
11 * the GNU General Public License as published by 11 * the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option) 12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version. 13 * any later version.
14 * 14 *
15 * The SCTP reference implementation is distributed in the hope that it 15 * The SCTP reference implementation is distributed in the hope that it
16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied 16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * ************************ 17 * ************************
18 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details. 19 * See the GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with GNU CC; see the file COPYING. If not, write to 22 * along with GNU CC; see the file COPYING. If not, write to
23 * the Free Software Foundation, 59 Temple Place - Suite 330, 23 * the Free Software Foundation, 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA. 24 * Boston, MA 02111-1307, USA.
25 * 25 *
26 * Please send any bug reports or fixes you make to the 26 * Please send any bug reports or fixes you make to the
27 * email address(es): 27 * email address(es):
28 * lksctp developers <lksctp-developers@lists.sourceforge.net> 28 * lksctp developers <lksctp-developers@lists.sourceforge.net>
29 * 29 *
30 * Or submit a bug report through the following website: 30 * Or submit a bug report through the following website:
31 * http://www.sf.net/projects/lksctp 31 * http://www.sf.net/projects/lksctp
32 * 32 *
33 * Written or modified by: 33 * Written or modified by:
34 * Dinakaran Joseph 34 * Dinakaran Joseph
35 * Jon Grimm <jgrimm@us.ibm.com> 35 * Jon Grimm <jgrimm@us.ibm.com>
36 * Sridhar Samudrala <sri@us.ibm.com> 36 * Sridhar Samudrala <sri@us.ibm.com>
37 * 37 *
38 * Any bugs reported given to us we will try to fix... any fixes shared will 38 * Any bugs reported given to us we will try to fix... any fixes shared will
39 * be incorporated into the next SCTP release. 39 * be incorporated into the next SCTP release.
40 */ 40 */
@@ -135,10 +135,10 @@ static const __u32 crc_c[256] = {
135 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E, 135 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
136 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351, 136 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351,
137}; 137};
138 138
139__u32 sctp_start_cksum(__u8 *buffer, __u16 length) 139__u32 sctp_start_cksum(__u8 *buffer, __u16 length)
140{ 140{
141 __u32 crc32 = ~(__u32) 0; 141 __u32 crc32 = ~(__u32) 0;
142 __u32 i; 142 __u32 i;
143 143
144 /* Optimize this routine to be SCTP specific, knowing how 144 /* Optimize this routine to be SCTP specific, knowing how
@@ -147,7 +147,7 @@ __u32 sctp_start_cksum(__u8 *buffer, __u16 length)
147 147
148 /* Calculate CRC up to the checksum. */ 148 /* Calculate CRC up to the checksum. */
149 for (i = 0; i < (sizeof(struct sctphdr) - sizeof(__u32)); i++) 149 for (i = 0; i < (sizeof(struct sctphdr) - sizeof(__u32)); i++)
150 CRC32C(crc32, buffer[i]); 150 CRC32C(crc32, buffer[i]);
151 151
152 /* Skip checksum field of the header. */ 152 /* Skip checksum field of the header. */
153 for (i = 0; i < sizeof(__u32); i++) 153 for (i = 0; i < sizeof(__u32); i++)
@@ -175,13 +175,13 @@ __u32 sctp_update_copy_cksum(__u8 *to, __u8 *from, __u16 length, __u32 crc32)
175 __u32 i; 175 __u32 i;
176 __u32 *_to = (__u32 *)to; 176 __u32 *_to = (__u32 *)to;
177 __u32 *_from = (__u32 *)from; 177 __u32 *_from = (__u32 *)from;
178 178
179 for (i = 0; i < (length/4); i++) { 179 for (i = 0; i < (length/4); i++) {
180 _to[i] = _from[i]; 180 _to[i] = _from[i];
181 CRC32C(crc32, from[i*4]); 181 CRC32C(crc32, from[i*4]);
182 CRC32C(crc32, from[i*4+1]); 182 CRC32C(crc32, from[i*4+1]);
183 CRC32C(crc32, from[i*4+2]); 183 CRC32C(crc32, from[i*4+2]);
184 CRC32C(crc32, from[i*4+3]); 184 CRC32C(crc32, from[i*4+3]);
185 } 185 }
186 186
187 return crc32; 187 return crc32;