X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FIpChecksum.hh;h=a8ea1ff2129efb7b599e55acc23d27f58fd530c1;hb=5443435c4c2b6e4386c5334b5b8358273f2bae93;hp=7efb55d6fe6a1e3cea438ad97059e46110bbc97e;hpb=a18d131c38ffe7178ea4736ed3f584125e9903ae;p=senf.git diff --git a/Utils/IpChecksum.hh b/Utils/IpChecksum.hh index 7efb55d..a8ea1ff 100644 --- a/Utils/IpChecksum.hh +++ b/Utils/IpChecksum.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,8 +23,8 @@ /** \file \brief IpChecksum public header */ -#ifndef HH_IpChecksum_ -#define HH_IpChecksum_ 1 +#ifndef HH_SENF_Utils_IpChecksum_ +#define HH_SENF_Utils_IpChecksum_ 1 // Custom includes #include @@ -34,7 +34,17 @@ namespace senf { - /** \brief + /** \brief 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 \e 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 \e even number of zero bytes + without changing the checksum value. */ class IpChecksum { @@ -51,12 +61,13 @@ namespace senf { ///@} /////////////////////////////////////////////////////////////////////////// - void feed(boost::uint8_t byte); + void feed(boost::uint8_t byte); ///< Feed single byte template void feed(InputIterator b, InputIterator e); + ///< Feed range of bytes - boost::uint16_t sum() const; + boost::uint16_t sum() const; ///< Calculate checksum protected: