]> git.proxmox.com Git - qemu.git/blame - include/net/checksum.h
hw: move headers to include/
[qemu.git] / include / net / checksum.h
CommitLineData
7200ac3c
MM
1/*
2 * IP checksumming functions.
3 * (c) 2008 Gerd Hoffmann <kraxel@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; under version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef QEMU_NET_CHECKSUM_H
19#define QEMU_NET_CHECKSUM_H
20
21#include <stdint.h>
22
5acf5ea4 23uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq);
7200ac3c
MM
24uint16_t net_checksum_finish(uint32_t sum);
25uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
26 uint8_t *addrs, uint8_t *buf);
27void net_checksum_calculate(uint8_t *data, int length);
28
5acf5ea4
DF
29static inline uint32_t
30net_checksum_add(int len, uint8_t *buf)
31{
32 return net_checksum_add_cont(len, buf, 0);
33}
34
35static inline uint16_t
36net_raw_checksum(uint8_t *data, int length)
37{
38 return net_checksum_finish(net_checksum_add(length, data));
39}
40
84026301
DF
41/**
42 * net_checksum_add_iov: scatter-gather vector checksumming
43 *
44 * @iov: input scatter-gather array
45 * @iov_cnt: number of array elements
46 * @iov_off: starting iov offset for checksumming
47 * @size: length of data to be checksummed
48 */
49uint32_t net_checksum_add_iov(const struct iovec *iov,
50 const unsigned int iov_cnt,
51 uint32_t iov_off, uint32_t size);
52
7200ac3c 53#endif /* QEMU_NET_CHECKSUM_H */