FACT++  1.0
bool checkIntLocation ( IntItemNode *  node)

Definition at line 3619 of file feeserver.c.

References calculateChecksum().

Referenced by monitorIntValues().

3619  {
3620  if (node->intItem->location == node->locBackup) {
3621  // locations are identical, so no bitflip
3622  return true;
3623  }
3624  // locations are not identical, check further
3625 
3626  if (node->checksum == calculateChecksum((unsigned char*)
3627  &(node->intItem->location), sizeof(volatile int*))) {
3628  // checksum tells, that first location should be valid, repair backup
3629  node->locBackup = node->intItem->location;
3630  return true;
3631  }
3632  // original location or first checksum is wrong, continue checking
3633 
3634  if (node->checksum == calculateChecksum((unsigned char*)
3635  &(node->locBackup), sizeof(volatile int*))) {
3636  // checksum tells, that location backup should be valid, repair original
3637  node->intItem->location = node->locBackup;
3638  return true;
3639  }
3640  // location backup or first checksum is wrong, continue checking
3641 
3642  if (node->checksum == node->checksumBackup) {
3643  // it seems that location and location backup are wrong
3644  // or checksum value runs banana, not repairable
3645  return false;
3646  }
3647  // it seems that first checksum is wrong
3648  // try to fix with second checksum
3649 
3650  if (node->checksumBackup == calculateChecksum((unsigned char*)
3651  &(node->intItem->location), sizeof(volatile int*))) {
3652  // checksum backup tells, that first location should be valid, repair backup
3653  node->locBackup = node->intItem->location;
3654  // repair first checksum
3655  node->checksum = node->checksumBackup;
3656  return true;
3657  }
3658  // original location or second checksum is wrong, continue checking
3659 
3660  if (node->checksumBackup == calculateChecksum((unsigned char*)
3661  &(node->locBackup), sizeof(volatile int*))) {
3662  // checksum backup tells, that location backup should be valid, repair original
3663  node->intItem->location = node->locBackup;
3664  // repair checksum
3665  node->checksum = node->checksumBackup;
3666  return true;
3667  }
3668  // value is totally banana, no chance to fix
3669  return false;
3670 }
unsigned int calculateChecksum(unsigned char *buffer, int size)
Definition: feeserver.c:2372
Definition: dns.c:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function: