srecord: srecord::fletcher16 Class Reference

srecord 1.65.0

Loading...
Searching...
No Matches
srecord::fletcher16 Class Reference

The fletcher16 class is used to represent the running value of a 16-bit Fletcher's Checksum of series of bytes. More...

`#include <fletcher16.h>`

## Public Member Functions
virtual | ~fletcher16 ()
| The destructor.
| fletcher16 (unsigned char sum1=0, unsigned char sum2=0, int answer=-1, endian_t end=endian_little)
| The default constructor.
| fletcher16 (const fletcher16 &)
| The copy constructor.
fletcher16 & | operator= (const fletcher16 &)
| The assignment operator.
unsigned short | get () const
| The get method is used to obtain the running value of the cyclic redundancy check.
void | next (unsigned char)
| The next method is used to advance the state by one byte.
void | nextbuf (const void *data, size_t data_size)
| The nextbuf method is used to advance the state by a series of bytes.

## Detailed Description

The fletcher16 class is used to represent the running value of a 16-bit Fletcher's Checksum of series of bytes.

http://en.wikipedia.org/wiki/Fletcher%27s_checksum

Fletcher's checksum is one of several types of checksum algorithms, which are relatively simple processes used by computers to check the integrity of data.

The implementation of the Fletcher-32 is very similar to the Adler-32 algorithm but several differences should be noted. Fletcher wraps around at modulo 65535 while Adler wraps at the prime 65521. In other words, Fletcher adds overflow bits (16-31) into its sum; while Adler multiplies those bits by 15, then adds the product into its sum. Fletcher-32 works on 16 bit data while Adler works on 8 bit data.

It is designed to overcome some of the inadequacies of simply summing all the bytes as in the original checksum. Fletcher's checksum, unlike the original checksum, can detect the inserting/deleting of zero value bytes, the reordering of bytes, and the incrementing and decrementing of bytes in opposite directions.

Fletcher's checksum is described in RFC 1146. You can also find information about generating (as well as verifying) such a checksum in Annex B of RFC 905.

Fletcher-32 is slightly more reliable than Adler-32.[1]

Definition at line 58 of file fletcher16.h.

## Constructor & Destructor Documentation

## ◆ ~fletcher16()

virtual srecord::fletcher16::~fletcher16 | ( |  | ) |
| virtual

The destructor.

## ◆ fletcher16() [1/2]

srecord::fletcher16::fletcher16 | ( | unsigned char | sum1 = 0,
|  | unsigned char | sum2 = 0,
|  | int | answer = -1,
|  | endian_t | end = endian_little )

The default constructor.

Parameters

  sum1 | The seed value for sum1. Defaults to 0xFF.
  sum2 | The seed value for sum2. Defaults to 0xFF.
  answer | Set this to -1 to be completely ignored. If >= 0, this is the desired outcome if the checksum includes the checksum itself. The checksum returned will be calculated to return this desired outcome, when traversed, rather than a pure Fletcher-16 checksum.
  end | The endian-ness of the checksum. This is needed to manipulate the answer. Ignored if `answer` is ignored.

References srecord::endian_little.

Referenced by fletcher16(), and operator=().

## ◆ fletcher16() [2/2]

srecord::fletcher16::fletcher16 | ( | const fletcher16 & |  | ) |

The copy constructor.

References fletcher16().

## Member Function Documentation

## ◆ operator=()

fletcher16 & srecord::fletcher16::operator= | ( | const fletcher16 & |  | ) |

The assignment operator.

References fletcher16().

## ◆ get()

unsigned short srecord::fletcher16::get | ( |  | ) | const

The get method is used to obtain the running value of the cyclic redundancy check.

## ◆ next()

void srecord::fletcher16::next | ( | unsigned char |  | ) |

The next method is used to advance the state by one byte.

## ◆ nextbuf()

void srecord::fletcher16::nextbuf | ( | const void * | data,
|  | size_t | data_size )

The nextbuf method is used to advance the state by a series of bytes.

Parameters

  data | The data to be checksummed.
  data_size | The size of the data to be checksummed, in bytes.

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

- fletcher16.h