senf::IpChecksum Class Reference

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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ IpChecksum()

senf::IpChecksum::IpChecksum ( )

Member Function Documentation

◆ feed() [1/2]

void senf::IpChecksum::feed ( boost::uint8_t  byte)

Feed single byte.

◆ feed() [2/2]

template<class InputIterator >
void senf::IpChecksum::feed ( InputIterator  b,
InputIterator  e 
)

Feed range of bytes.

◆ sum()

boost::uint16_t senf::IpChecksum::sum ( ) const

Calculate checksum.


The documentation for this class was generated from the following file: