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

#include <XrdCksCalccrc32C.hh>

Inheritance diagram for XrdCksCalccrc32C:
Collaboration diagram for XrdCksCalccrc32C:

Public Member Functions

 XrdCksCalccrc32C ()
virtual ~XrdCksCalccrc32C ()
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
XrdCksCalc * New () override
const char * Type (int &csSz) 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 42 of file XrdCksCalccrc32C.hh.

Constructor & Destructor Documentation

◆ XrdCksCalccrc32C()

XrdCksCalccrc32C::XrdCksCalccrc32C ( )
inline

Definition at line 64 of file XrdCksCalccrc32C.hh.

64{Init();}
void Init() override

References Init().

Referenced by New().

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

◆ ~XrdCksCalccrc32C()

virtual XrdCksCalccrc32C::~XrdCksCalccrc32C ( )
inlinevirtual

Definition at line 65 of file XrdCksCalccrc32C.hh.

65{}

Member Function Documentation

◆ Combinable()

bool XrdCksCalccrc32C::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 46 of file XrdCksCalccrc32C.hh.

46{return true;}

◆ Combine() [1/2]

const char * XrdCksCalccrc32C::Combine ( const char * Cksum,
int DLen )
overridevirtual

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 24 of file XrdCksCalccrc32C.cc.

25{
26 uint32_t crc2;
27 memcpy(&crc2, Cksum, sizeof(crc2));
28
29#ifndef Xrd_Big_Endian
30 crc2 = ntohl(crc2);
31#endif
32
33 C32CResult = XrdOucCRC::Combine32C(C32CResult, crc2, (size_t)DLen);
34 return Final();
35}
char * Final() override
static uint32_t Combine32C(uint32_t Cksum1, uint32_t Cksum2, int DLen)
Definition XrdOucCRC.cc:222

References XrdOucCRC::Combine32C(), and Final().

Here is the call graph for this function:

◆ Combine() [2/2]

const char * XrdCksCalccrc32C::Combine ( const char * Cksum1,
const char * Cksum2,
int DLen )
overridevirtual

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 41 of file XrdCksCalccrc32C.cc.

43{
44 uint32_t crc1, crc2;
45 memcpy(&crc1, Cksum1, sizeof(crc1));
46 memcpy(&crc2, Cksum2, sizeof(crc2));
47
48#ifndef Xrd_Big_Endian
49 crc1 = ntohl(crc1);
50 crc2 = ntohl(crc2);
51#endif
52
53 TheResult = XrdOucCRC::Combine32C(crc1, crc2, (size_t)DLen);
54
55#ifndef Xrd_Big_Endian
56 TheResult = htonl(TheResult);
57#endif
58 return (char *)&TheResult;
59}

References XrdOucCRC::Combine32C().

Here is the call graph for this function:

◆ Final()

char * XrdCksCalccrc32C::Final ( )
overridevirtual

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 65 of file XrdCksCalccrc32C.cc.

66{
67 TheResult = C32CResult;
68#ifndef Xrd_Big_Endian
69 TheResult = htonl(TheResult);
70#endif
71 return (char *)&TheResult;
72}

Referenced by Combine().

Here is the caller graph for this function:

◆ Init()

void XrdCksCalccrc32C::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 55 of file XrdCksCalccrc32C.hh.

55{C32CResult = C32C_XINIT;}

Referenced by XrdCksCalccrc32C().

Here is the caller graph for this function:

◆ New()

XrdCksCalc * XrdCksCalccrc32C::New ( )
overridevirtual

Get a new instance of the underlying checksum calculation object.

Returns
the checksum calculation object.

Implements XrdCksCalc.

Definition at line 78 of file XrdCksCalccrc32C.cc.

79{ return (XrdCksCalc *)new XrdCksCalccrc32C; }
XrdCksCalc()
Constructor.

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

Here is the call graph for this function:

◆ Type()

const char * XrdCksCalccrc32C::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 59 of file XrdCksCalccrc32C.hh.

60 {csSz = sizeof(TheResult); return "crc32c";}

◆ Update()

void XrdCksCalccrc32C::Update ( const char * Buff,
int BLen )
overridevirtual

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 85 of file XrdCksCalccrc32C.cc.

86{
87 C32CResult = (unsigned int)XrdOucCRC::Calc32C(Buff, BLen, C32CResult);
88}
static uint32_t Calc32C(const void *data, size_t count, uint32_t prevcs=0)
Definition XrdOucCRC.cc:190

References XrdOucCRC::Calc32C().

Here is the call graph for this function:

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