mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
Checksum-related utility functions
net_checksum_add_cont() checksum calculation for scattered data with odd chunk sizes net_raw_checksum() checksum calculation for a buffer Signed-off-by: Dmitry Fleytman <dmitry@daynix.com> Signed-off-by: Yan Vugenfirer <yan@daynix.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
20048d0a12
commit
5acf5ea4bc
2 changed files with 20 additions and 7 deletions
|
@ -20,10 +20,22 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t net_checksum_add(int len, uint8_t *buf);
|
||||
uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq);
|
||||
uint16_t net_checksum_finish(uint32_t sum);
|
||||
uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
|
||||
uint8_t *addrs, uint8_t *buf);
|
||||
void net_checksum_calculate(uint8_t *data, int length);
|
||||
|
||||
static inline uint32_t
|
||||
net_checksum_add(int len, uint8_t *buf)
|
||||
{
|
||||
return net_checksum_add_cont(len, buf, 0);
|
||||
}
|
||||
|
||||
static inline uint16_t
|
||||
net_raw_checksum(uint8_t *data, int length)
|
||||
{
|
||||
return net_checksum_finish(net_checksum_add(length, data));
|
||||
}
|
||||
|
||||
#endif /* QEMU_NET_CHECKSUM_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue