#include <senf/Utils/IpChecksum.hh>
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 49 of file IpChecksum.hh.
Public Member Functions |
|
void | feed (boost::uint8_t byte) |
Feed single byte. |
|
template<class InputIterator > | |
void | feed (InputIterator b, InputIterator e) |
Feed range of bytes. |
|
boost::uint16_t | sum () const |
Calculate checksum. |
|
Structors and default members |
|
IpChecksum () |
senf::IpChecksum:: | ||||
IpChecksum | () | |||
Definition at line 31 of file IpChecksum.cci.
void senf::IpChecksum:: | ||||
feed | ( | InputIterator | b, | |
InputIterator | e | ) | ||
Feed range of bytes.
Definition at line 34 of file IpChecksum.cti.
void senf::IpChecksum:: | ||||
feed | ( | boost::uint8_t | byte | ) |
Feed single byte.
Definition at line 35 of file IpChecksum.cci.
boost::uint16_t senf::IpChecksum:: | ||||
sum | () | |||
Calculate checksum.
Definition at line 41 of file IpChecksum.cci.