IpChecksum.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_IpChecksum_
18 #define HH_SENF_Utils_IpChecksum_ 1
19 
20 // Custom includes
21 #include <boost/cstdint.hpp>
22 
23 //#include "IpChecksum.mpp"
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
40  class IpChecksum
41  {
42  public:
43  //-////////////////////////////////////////////////////////////////////////
44  // Types
45 
46  //-////////////////////////////////////////////////////////////////////////
48  //\{
49 
50  IpChecksum();
51 
52  //\}
53  //-////////////////////////////////////////////////////////////////////////
54 
55  void feed(boost::uint8_t byte);
56 
57  template <class InputIterator>
58  void feed(InputIterator b, InputIterator e);
60 
61  boost::uint16_t sum() const;
62 
63  protected:
64 
65  private:
66  boost::uint32_t sum_;
67  bool odd_;
68  };
69 
70 
71 }
72 
73 //-/////////////////////////////////////////////////////////////////////////////////////////////////
74 #include "IpChecksum.cci"
75 //#include "IpChecksum.ct"
76 #include "IpChecksum.cti"
77 #endif
78 
79 
80 // Local Variables:
81 // mode: c++
82 // fill-column: 100
83 // comment-column: 40
84 // c-file-style: "senf"
85 // indent-tabs-mode: nil
86 // ispell-local-dictionary: "american"
87 // compile-command: "scons -u test"
88 // End:
boost::uint8_t byte
boost::uint16_t sum() const
Calculate checksum.
Calculate TCP/IP 16bit checksum value.
Definition: IpChecksum.hh:40
void feed(boost::uint8_t byte)
Feed single byte.