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

#include <XrdOucCRC.hh>

+ Collaboration diagram for XrdOucCRC:

Public Member Functions

 XrdOucCRC ()
 
 ~XrdOucCRC ()
 

Static Public Member Functions

static void Calc32C (const void *data, size_t count, uint32_t *csval)
 
static uint32_t Calc32C (const void *data, size_t count, uint32_t prevcs=0)
 
static uint32_t CRC32 (const unsigned char *data, int count)
 
static bool Ver32C (const void *data, size_t count, const uint32_t *csval, bool *valok)
 
static int Ver32C (const void *data, size_t count, const uint32_t *csval, uint32_t &valcs)
 
static bool Ver32C (const void *data, size_t count, const uint32_t *csval, uint32_t *valcs)
 
static bool Ver32C (const void *data, size_t count, const uint32_t csval, uint32_t *csbad=0)
 

Detailed Description

Definition at line 38 of file XrdOucCRC.hh.

Constructor & Destructor Documentation

◆ XrdOucCRC()

XrdOucCRC::XrdOucCRC ( )
inline

Definition at line 150 of file XrdOucCRC.hh.

150{}

◆ ~XrdOucCRC()

XrdOucCRC::~XrdOucCRC ( )
inline

Definition at line 151 of file XrdOucCRC.hh.

151{}

Member Function Documentation

◆ Calc32C() [1/2]

void XrdOucCRC::Calc32C ( const void * data,
size_t count,
uint32_t * csval )
static

Compute a CRC32C page checksums using hardware assist if available.

Parameters
dataPointer to the data whose checksum it to be computed.
countThe number of bytes pointed to by data.
csvalPointer to a vector to hold individual page checksums. The vector must be sized: (count/XrdSys::PageSize + (countXrdSys::PageSize != 0)). On return, each element of csval holds the checksum for the associated page.

Definition at line 200 of file XrdOucCRC.cc.

201{
202 int i, numpages = count/XrdSys::PageSize;
203 const uint8_t* dataP = (const uint8_t*)data;
204
205// Calculate the CRC32C for each page
206//
207 for (i = 0; i < numpages; i++)
208 {csval[i] = crc32c(0, dataP, XrdSys::PageSize);
209 count -= XrdSys::PageSize;
210 dataP += XrdSys::PageSize;
211 }
212
213// if there is anything left, calculate that as well
214//
215 if (count > 0) csval[i] = crc32c(0, dataP, count);
216}
uint32_t crc32c(uint32_t crc, void const *buf, size_t len)
static const int PageSize

References crc32c(), and XrdSys::PageSize.

+ Here is the call graph for this function:

◆ Calc32C() [2/2]

uint32_t XrdOucCRC::Calc32C ( const void * data,
size_t count,
uint32_t prevcs = 0 )
static

Compute a CRC32C checksum using hardware assist if available.

Parameters
dataPointer to the data whose checksum it to be computed.
countThe number of bytes pointed to by data.
prevcsThe previous checksum value. The initial checksum of checksum sequence should be zero, the default.
Returns
The CRC32C checksum.

Definition at line 190 of file XrdOucCRC.cc.

191{
192
193// Return the checksum
194//
195 return crc32c(prevcs, data, count);
196}

References crc32c().

Referenced by XrdOfsCPFile::Append(), XrdOssCsiPages::apply_sequential_aligned_modify(), XrdOssCsiPages::BasicConsistencyCheck(), XrdXrootdPgwBadCS::boInfo(), XrdOssCsiCrcUtils::crc32c_combine(), XrdOssCsiCrcUtils::crc32c_extendwith_zero(), XrdOssCsiCrcUtils::crc32c_split2(), XrdOfsCPFile::Create(), XrdOucPgrwUtils::csCalc(), XrdOucPgrwUtils::csCalc(), XrdOssCsiPages::FetchRangeAligned(), XrdOssCsiPages::FetchRangeUnaligned(), XrdOssCsiPages::FetchRangeUnaligned_postblock(), XrdOssCsiPages::FetchRangeUnaligned_preblock(), XrdCl::PgReadSubstitutionHandler::HandleResponse(), XrdCl::EcPgReadResponseHandler::HandleResponse(), main(), XrdOssCsiTagstoreFile::Open(), XrdOssCsiPages::pgDoCalc(), XrdOssCsiPages::StoreRangeUnaligned_postblock(), XrdOssCsiPages::StoreRangeUnaligned_preblock(), XrdOssCsiPages::truncate(), XrdCl::XRootDTransport::UnMarchalStatusMore(), XrdCl::XRootDTransport::UnMarshalStatusBody(), and XrdCksCalccrc32C::Update().

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

◆ CRC32()

uint32_t XrdOucCRC::CRC32 ( const unsigned char * data,
int count )
static

Compute a CRC32 checksum.

Note
This is a historical method as it uses the very slow CRC32 algoritm.
Parameters
dataPointer to the data whose checksum it to be computed.
countThe number of bytes pointed to by data.
Returns
The CRC32 checksum.

Definition at line 171 of file XrdOucCRC.cc.

172{
173 const unsigned int CRC32_XINIT = 0xffffffff;
174 const unsigned int CRC32_XOROT = 0xffffffff;
175 unsigned int crc = CRC32_XINIT;
176
177// Process each byte
178//
179 while(reclen-- > 0) crc = crctable[(crc ^ *p++) & 0xff] ^ (crc >> 8);
180
181// Return XOR out value
182//
183 return crc ^ CRC32_XOROT;
184}

Referenced by XrdOfsHanKey::XrdOfsHanKey(), XrdOucReqID::XrdOucReqID(), XrdOucReqID::Index(), and XrdCmsKey::setHash().

+ Here is the caller graph for this function:

◆ Ver32C() [1/4]

bool XrdOucCRC::Ver32C ( const void * data,
size_t count,
const uint32_t * csval,
bool * valok )
static

Verify a CRC32C page checksums using hardware assist if available.

Parameters
dataPointer to the data whose checksum it to be verified.
countThe number of bytes pointed to by data.
csvalPointer to a vector of expected page checksums. The vector must be sized (count/PageSize+(countPageSize != 0)).
valokPointer to a vector of the same size as csval to hold the results of the comparison (true matches, o/w false).
Returns
True if all the checksums match with each element of valok set to true. Otherwise, false is returned and false is set in valok for each page that did not match the expected checksum.

Definition at line 274 of file XrdOucCRC.cc.

276{
277 int i, numpages = count/XrdSys::PageSize;
278 const uint8_t* dataP = (const uint8_t*)data;
279 uint32_t actualCS;
280 bool retval = true;
281
282// Calculate the CRC32C for each page and make sure it is the same.
283//
284 for (i = 0; i < numpages; i++)
285 {
286 actualCS = crc32c(0, dataP, XrdSys::PageSize);
287 if (csval[i] == actualCS) valok[i] = true;
288 else valok[i] = retval = false;
289 count -= XrdSys::PageSize;
290 dataP += XrdSys::PageSize;
291 }
292
293// if there is anything left, verify that as well
294//
295 if (count > 0)
296 {
297 actualCS = crc32c(0, dataP, count);
298 if (csval[i] == actualCS) valok[i] = true;
299 else valok[i] = retval = false;
300 }
301
302// All done.
303//
304 return retval;
305}

References crc32c(), and XrdSys::PageSize.

+ Here is the call graph for this function:

◆ Ver32C() [2/4]

int XrdOucCRC::Ver32C ( const void * data,
size_t count,
const uint32_t * csval,
uint32_t & valcs )
static

Verify a CRC32C page checksums using hardware assist if available.

Parameters
dataPointer to the data whose checksum it to be verified.
countThe number of bytes pointed to by data.
csvalPointer to a vector of expected page checksums. The vector must be sized: (count/XrdSys::PageSize + (countXrdSys::PageSize != 0)).
valcsWhere the computed checksum is returned for the page whose verification failed; otherwise it is untouched.
Returns
-1 if all the checksums match. Otherwise, the non-negative index into csval whose checksum does not match.

Definition at line 236 of file XrdOucCRC.cc.

238{
239 int i, numpages = count/XrdSys::PageSize;
240 const uint8_t* dataP = (const uint8_t*)data;
241 uint32_t actualCS;
242
243// Calculate the CRC32C for each page and make sure it is the same.
244//
245 for (i = 0; i < numpages; i++)
246 {
247 actualCS = crc32c(0, dataP, XrdSys::PageSize);
248 if (csval[i] != actualCS)
249 {valcs = actualCS;
250 return i;
251 }
252 count -= XrdSys::PageSize;
253 dataP += XrdSys::PageSize;
254 }
255
256// if there is anything left, verify that as well
257//
258 if (count > 0)
259 {
260 actualCS = crc32c(0, dataP, count);
261 if (csval[i] != actualCS)
262 {valcs = actualCS;
263 return i;
264 }
265 }
266
267// Everything matched.
268//
269 return -1;
270}

References crc32c(), and XrdSys::PageSize.

+ Here is the call graph for this function:

◆ Ver32C() [3/4]

bool XrdOucCRC::Ver32C ( const void * data,
size_t count,
const uint32_t * csval,
uint32_t * valcs )
static

Verify a CRC32C page checksums using hardware assist if available.

Parameters
dataPointer to the data whose checksum it to be verified.
countThe number of bytes pointed to by data.
csvalPointer to a vector of expected page checksums. The vector must be sized (count/PageSize+(countPageSize != 0)).
valcsPointer to a vector of the same size as csval to hold the computed checksum.
Returns
True if all the checksums match; false otherwise.

Definition at line 309 of file XrdOucCRC.cc.

311{
312 int i, numpages = count/XrdSys::PageSize;
313 const uint8_t* dataP = (const uint8_t*)data;
314 bool retval = true;
315
316// Calculate the CRC32C for each page and make sure it is the same.
317//
318 for (i = 0; i < numpages; i++)
319 {
320 valcs[i] = crc32c(0, dataP, XrdSys::PageSize);
321 if (csval[i] != valcs[i]) retval = false;
322 count -= XrdSys::PageSize;
323 dataP += XrdSys::PageSize;
324 }
325
326// if there is anything left, verify that as well
327//
328 if (count > 0)
329 {
330 valcs[i] = crc32c(0, dataP, count);
331 if (csval[i] != valcs[i]) retval = false;
332 }
333
334// All done.
335//
336 return retval;
337}

References crc32c(), and XrdSys::PageSize.

+ Here is the call graph for this function:

◆ Ver32C() [4/4]

bool XrdOucCRC::Ver32C ( const void * data,
size_t count,
const uint32_t csval,
uint32_t * csbad = 0 )
static

Verify a CRC32C checksum using hardware assist if available.

Parameters
dataPointer to the data whose checksum it to be verified.
countThe number of bytes pointed to by data.
csvalThe expected checksum.
csbadIf csbad is not nil, the computed checksum is returned.
Returns
True if the expected checksum equals the actual checksum; otherwise, false is returned.

Definition at line 222 of file XrdOucCRC.cc.

224{
225 uint32_t actualCS;
226
227// Verify the checksum
228//
229 actualCS = crc32c(0, data, count);
230 if (valcs) *valcs = actualCS;
231 return csval == actualCS;
232}

References crc32c().

Referenced by XrdOucPgrwUtils::csVer(), XrdOssCsiPages::pgWritePrelockCheck(), and XrdOfsCPFile::RestoreInfo().

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

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