XRootD
Loading...
Searching...
No Matches
XrdCksCalcadler32 Class Reference

#include <XrdCksCalcadler32.hh>

Inheritance diagram for XrdCksCalcadler32:
Collaboration diagram for XrdCksCalcadler32:

Public Member Functions

 XrdCksCalcadler32 ()
virtual ~XrdCksCalcadler32 ()
bool Combinable () override
const char * Combine (const char *Cksum, int DLen) override
const char * Combine (const char *Cksum1, const char *Cksum2, int DLen) override
char * Final () override
void Init () override
XrdCksCalcNew () override
const char * Type (int &csSize) override
void Update (const char *Buff, int BLen) override
Public Member Functions inherited from XrdCksCalc
 XrdCksCalc ()
 Constructor.
virtual ~XrdCksCalc ()
 Destructor.
virtual char * Calc (const char *Buff, int BLen)
virtual char * Current ()
virtual void Recycle ()
 Recycle the checksum object as it is no longer needed. A default is given.

Detailed Description

Definition at line 82 of file XrdCksCalcadler32.hh.

Constructor & Destructor Documentation

◆ XrdCksCalcadler32()

XrdCksCalcadler32::XrdCksCalcadler32 ( )
inline

Definition at line 134 of file XrdCksCalcadler32.hh.

134{Init();}

References Init().

Referenced by New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~XrdCksCalcadler32()

virtual XrdCksCalcadler32::~XrdCksCalcadler32 ( )
inlinevirtual

Definition at line 135 of file XrdCksCalcadler32.hh.

135{}

Member Function Documentation

◆ Combinable()

bool XrdCksCalcadler32::Combinable ( )
inlineoverridevirtual

Indicate whether or not checksums are combinable for this checksum.

Returns
True if checksums are combinable, false otherwise.
Note
The default is false as combinable checksums are possible for only a few checksum algorithms (e.g. adler and crc). Even then, combining checksums is an optimization not a neccisity.

Reimplemented from XrdCksCalc.

Definition at line 86 of file XrdCksCalcadler32.hh.

86{return true;}

◆ Combine() [1/2]

const char * XrdCksCalcadler32::Combine ( const char * Cksum,
int DLen )
inlineoverridevirtual

Combine current checksum with a checksum computed for an adjacent block.

Parameters
Cksum-> Pointer to the binary checksum of the same algorithm.
DLen-> Length of the data used to compute the checksum.
Returns
Pointer to the new checksum after combining. This checksum becomes the current checksum. If a nil pointer is returned, this algorithm does not support checksum combining.
Note
Warning! The supplied checkums must have been computed for an adjacent block of data for the current checksum otherwise the combined checksum will be invalid.

Reimplemented from XrdCksCalc.

Definition at line 88 of file XrdCksCalcadler32.hh.

89 {uint32_t adler2 = getCS(Cksum);
90 uint32_t adler1 = (unSum2 << 16) | unSum1;
91 uLong newcs = adler32_combine(adler1, adler2, DLen);
92 unSum1 = newcs & 0xffff;
93 unSum2 = (newcs >> 16) & 0xffff;
94 return Final();
95 }
char * Final() override

References Final().

Here is the call graph for this function:

◆ Combine() [2/2]

const char * XrdCksCalcadler32::Combine ( const char * Cksum1,
const char * Cksum2,
int DLen )
inlineoverridevirtual

Combine a checksum with a checksum computed for an adjacent block.

Parameters
Cksum1-> Pointer to a binary checksum.
Cksum2-> Pointer to a binary checksum of the same type.
DLen-> Length of the data used to compute the checksum.
Returns
Pointer to the new checksum after combining. The current checksum is not modified. If a nil pointer is returned, this algorithm does not support checksum combining.
Note
Warning! The Cksum2 must have been computed for the adjacent block of data relative to the computation of Cksum1 otherwise the combined checksum will be invalid.

Reimplemented from XrdCksCalc.

Definition at line 97 of file XrdCksCalcadler32.hh.

98 {uint32_t adler1 = getCS(Cksum1);
99 uint32_t adler2 = getCS(Cksum2);
100 AdlerValue = (uint32_t)adler32_combine(adler1, adler2, DLen);
101#ifndef Xrd_Big_Endian
102 AdlerValue = htonl(AdlerValue);
103#endif
104 return (const char *)&AdlerValue;
105 }

◆ Final()

char * XrdCksCalcadler32::Final ( )
inlineoverridevirtual

Get the actual checksum in binary format.

Returns
the checksum value in binary format. The pointer to the value becomes invalid once the associated object is deleted.

Implements XrdCksCalc.

Definition at line 107 of file XrdCksCalcadler32.hh.

108 {AdlerValue = (unSum2 << 16) | unSum1;
109#ifndef Xrd_Big_Endian
110 AdlerValue = htonl(AdlerValue);
111#endif
112 return (char *)&AdlerValue;
113 }

Referenced by Combine().

Here is the caller graph for this function:

◆ Init()

void XrdCksCalcadler32::Init ( )
inlineoverridevirtual

Initializes data structures (must be called by constructor). This is always called to reuse the object for a new checksum.

Implements XrdCksCalc.

Definition at line 115 of file XrdCksCalcadler32.hh.

115{unSum1 = AdlerStart; unSum2 = 0;}

Referenced by XrdCksCalcadler32().

Here is the caller graph for this function:

◆ New()

XrdCksCalc * XrdCksCalcadler32::New ( )
inlineoverridevirtual

Get a new instance of the underlying checksum calculation object.

Returns
the checksum calculation object.

Implements XrdCksCalc.

Definition at line 117 of file XrdCksCalcadler32.hh.

117{return (XrdCksCalc *)new XrdCksCalcadler32;}
XrdCksCalc()
Constructor.

References XrdCksCalc::XrdCksCalc(), and XrdCksCalcadler32().

Here is the call graph for this function:

◆ Type()

const char * XrdCksCalcadler32::Type ( int & csSize)
inlineoverridevirtual

Get the checksum object algorithm name and the number bytes (i.e. size) required for the checksum value.

Parameters
csSize-> Parameter to hold the size of the checksum value.
Returns
the checksum algorithm's name. The name persists event after the checksum object is deleted.

Implements XrdCksCalc.

Definition at line 131 of file XrdCksCalcadler32.hh.

132 {csSize = sizeof(AdlerValue); return "adler32";}

◆ Update()

void XrdCksCalcadler32::Update ( const char * Buff,
int BLen )
inlineoverridevirtual

Compute a running checksum. This method may be called repeatedly for data segments; with Final() returning the full checksum.

Parameters
Buff-> Data to be checksummed.
BLen-> Length of the data in Buff.

Implements XrdCksCalc.

Definition at line 119 of file XrdCksCalcadler32.hh.

120 {int k;
121 unsigned char *buff = (unsigned char *)Buff;
122 while(BLen > 0)
123 {k = (BLen < AdlerNMax ? BLen : AdlerNMax);
124 BLen -= k;
125 while(k >= 16) {DO16(buff); k -= 16;}
126 if (k != 0) do {DO1(buff);} while (--k);
127 unSum1 %= AdlerBase; unSum2 %= AdlerBase;
128 }
129 }
#define DO16(buf)
#define DO1(buf)

References DO1, and DO16.


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