Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\checksum.c Create Date:2022-07-28 07:16:58
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:do_csum

Proto:static unsigned int do_csum(const unsigned char *buff, int len)

Type:unsigned int

Parameter:

TypeParameterName
const unsigned char *buff
intlen
49  result = 0
51  If len <= 0 Then Go to out
53  odd = 1 & buff
54  If odd Then
56  result += buff << 8
60  len--
61  buff++
63  If len >= 2 Then
64  If 2 & buff Then
65  result += buff
66  len -= 2
67  buff += 2
69  If len >= 4 Then
70  end = buff + (len & ~3)
71  carry = 0
72  Do
73  w = buff
74  buff += 4
75  result += carry
76  result += w
77  carry = w > result
78  When buff < end cycle
79  result += carry
80  result = (result & 0xffff) + (result >> 16)
82  If len & 2 Then
83  result += buff
84  buff += 2
87  If len & 1 Then result += buff
93  result = from32to16(result)
94  If odd Then result = result >> 8 & 0xff | (result & 0xff) << 8
96  out :
97  Return result
Caller
NameDescribe
ip_fast_csumThis is a version of ip_compute_csum() optimized for IP headers,* which always checksum on 4 octet boundaries.
csum_partialmputes the checksum of a memory block at buff, length len,* and adds in "sum" (32-bit)* returns a 32-bit number suitable for feeding into itself* or csum_tcpudp_magic* this function must be called with even lengths, except* for the last fragment, which
ip_compute_csumhis routine is used for miscellaneous IP-like checksums, mainly* in icmp.c