friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/Checksum.h
Go to the documentation of this file.
1 // EtherDune IP Checksum module
2 // Author: Javier Peletier <jm@friendev.com>
3 // Summary: memory-efficient algorithm to calculate total and partial network checksums
4 //
5 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
6 //
7 // This source is subject to the GPLv2 license.
8 // Please see the License.txt file for more information.
9 // All other rights reserved.
10 //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 
19 
20 #ifndef _CHECKSUM_h
21 #define _CHECKSUM_h
22 
23 #include <ACross.h>
24 
25 
26 class Checksum
27 {
28 public:
29  static uint16_t add(uint16_t a, uint16_t b);
30  static uint16_t add(uint16_t a, uint16_t b, bool odd);
31  static uint16_t calc(uint16_t len, const uint8_t *data);
32  static uint16_t calc(uint16_t checksum, uint16_t len, const uint8_t *data);
33 
34 };
35 
36 
37 #endif
38 
static uint16_t calc(uint16_t len, const uint8_t *data)
Calculates the checksum of the specified buffer in memory
Definition: Checksum.cpp:59
static uint16_t add(uint16_t a, uint16_t b)
Adds two checksums, taking carry into account.
Definition: Checksum.cpp:25
Contains functions to perform IP checksum operations.
Definition: Checksum.h:26