File Index
Files and directories
Sign in
FILE

checksum.h

File preview with syntax highlighting.

linux-6.19.14/include/net/sctp/checksum.h C
 1/* SPDX-License-Identifier: GPL-2.0-or-later */
 2/* SCTP kernel reference Implementation
 3 * Copyright (c) 1999-2001 Motorola, Inc.
 4 * Copyright (c) 2001-2003 International Business Machines, Corp.
 5 *
 6 * This file is part of the SCTP kernel reference Implementation
 7 *
 8 * SCTP Checksum functions
 9 *
10 * Please send any bug reports or fixes you make to the
11 * email address(es):
12 *    lksctp developers <linux-sctp@vger.kernel.org>
13 *
14 * Written or modified by:
15 *    Dinakaran Joseph
16 *    Jon Grimm <jgrimm@us.ibm.com>
17 *    Sridhar Samudrala <sri@us.ibm.com>
18 *    Vlad Yasevich <vladislav.yasevich@hp.com>
19 */
20
21#ifndef __sctp_checksum_h__
22#define __sctp_checksum_h__
23
24#include <linux/types.h>
25#include <linux/sctp.h>
26
27static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
28					unsigned int offset)
29{
30	struct sctphdr *sh = (struct sctphdr *)(skb->data + offset);
31	__le32 old = sh->checksum;
32	u32 new;
33
34	sh->checksum = 0;
35	new = ~skb_crc32c(skb, offset, skb->len - offset, ~0);
36	sh->checksum = old;
37	return cpu_to_le32(new);
38}
39
40#endif /* __sctp_checksum_h__ */
~/ Read-only file preview.