• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /**
16  * @defgroup checksum Checksum
17  * @ingroup linux
18  */
19 
20 #ifndef _LINUX_CHECKSUM_H
21 #define _LINUX_CHECKSUM_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 /**
28  * @ingroup checksum
29  * @brief Computes 32-bit intermediate sums.
30  *
31  * @par Description:
32  * This API is used to calculates the checksum of the buff, length len, and incorporates the result into the input
33  * parameter "wsum".
34  * @attention
35  * None.
36  *
37  * @param buf   [IN]he pointer to the data address.
38  * @param len   [IN]The number of bits to be checksum.
39  * @param wsum  [IN]The initial sum added to the results.
40  *
41  * @retval unsigned int   Checksum of the buffer.
42  * @par Dependency:
43  * <ul><li>checksum.h: the header file that contains the API declaration.</li></ul>
44  * @see None.
45  */
46 unsigned int csum_partial(const void *buf, int len, unsigned int wsum);
47 
48 /**
49  * @ingroup checksum
50  * @brief Copy and checksum.
51  *
52  * @par Description:
53  * This API is used to calculate the checksum of the buff, length len, incorporates the result into the input
54  * parameter "wsum", and copy the data.
55  * @attention
56  * None.
57  *
58  * @param src   [IN]The pointer to the source address.
59  * @param dst   [IN]The pointer to the destination address.
60  * @param len   [IN]The number of bits to be copied.
61  * @param wsum  [IN]The initial sum added to the results.
62  *
63  * @retval unsigned int   Checksum of the buffer.
64  * @par Dependency:
65  * <ul><li>checksum.h: the header file that contains the API declaration.</li></ul>
66  * @see None.
67  */
68 unsigned int csum_partial_copy_nocheck(const void *src, void *dst, int len, unsigned int wsum);
69 
70 /**
71  * @ingroup checksum
72  * @brief checksum.
73  *
74  * @par Description:
75  * This API is used to calculate the checksum.
76  * @attention
77  * <ul>
78  * <li>This function is for LWIP_CHKSUM.</li>
79  * </ul>
80  *
81  * @param buf   [IN]The pointer to the source address.
82  * @param len   [IN]The length of buff.
83  *
84  * @retval unsigned int   Checksum of the buffer.
85  * @par Dependency:
86  * <ul><li>checksum.h: the header file that contains the API declaration.</li></ul>
87  * @see None.
88  */
89 unsigned short in_cksum(const void *buf, int len);
90 
91 /**
92  * @ingroup checksum
93  * @brief Copy and checksum.
94  *
95  * @par Description:
96  * This API is used to calculate the checksum and copy the data.
97  * @attention
98  * <ul>
99  * <li>This function is for LWIP_CHKSUM_COPY.</li>
100  * </ul>
101  *
102  * @param src   [IN]The pointer to the source address.
103  * @param dst   [IN]The pointer to the destination address.
104  * @param len   [IN]The number of bits to be copied.
105  *
106  * @retval unsigned int   Checksum of the buffer.
107  * @par Dependency:
108  * <ul><li>checksum.h: the header file that contains the API declaration.</li></ul>
109  * @see None.
110  */
111 unsigned short in_cksum_copy(const void *src, void *dst, int len);
112 
113 #ifdef __cplusplus
114 }
115 #endif /* __cplusplus */
116 
117 #endif
118