Calculate TCP/IP 16bit checksum value. More...
#include <senf/Utils/IpChecksum.hh>
Public Member Functions | |
void | feed (boost::uint8_t byte) |
Feed single byte. More... | |
template<class InputIterator > | |
void | feed (InputIterator b, InputIterator e) |
Feed range of bytes. More... | |
boost::uint16_t | sum () const |
Calculate checksum. More... | |
Structors and default members | |
IpChecksum () | |
Calculate TCP/IP 16bit checksum value.
This class allows calculation of the 16bit checksum value as defined in the TCP/IP v4 RFC's. This checksum is not a CRC.
To calculate the checksum, you create an instance of IpChecksum. You then repeatedly call the feed() members to pass data in. After all data has been processed, the sum() member will return the calculated checksum.
The mathematical properties of the checksum allow to skip any even number of zero bytes without changing the checksum value.
Definition at line 40 of file IpChecksum.hh.
senf::IpChecksum::IpChecksum | ( | ) |
void senf::IpChecksum::feed | ( | boost::uint8_t | byte | ) |
Feed single byte.
void senf::IpChecksum::feed | ( | InputIterator | b, |
InputIterator | e | ||
) |
Feed range of bytes.
boost::uint16_t senf::IpChecksum::sum | ( | ) | const |
Calculate checksum.