FACT++  1.0
bool checkLocation ( ItemNode *  node)

Definition at line 2023 of file feeserver.c.

References calculateChecksum().

Referenced by monitorValues().

2023  {
2024  if (node->item->location == node->locBackup) {
2025  // locations are identical, so no bitflip
2026  return true;
2027  }
2028  // locations are not identical, check further
2029 
2030  if (node->checksum == calculateChecksum((unsigned char*)
2031  &(node->item->location), sizeof(volatile float*))) {
2032  // checksum tells, that first location should be valid, repair backup
2033  node->locBackup = node->item->location;
2034  return true;
2035  }
2036  // original location or first checksum is wrong, continue checking
2037 
2038  if (node->checksum == calculateChecksum((unsigned char*)
2039  &(node->locBackup), sizeof(volatile float*))) {
2040  // checksum tells, that location backup should be valid, repair original
2041  node->item->location = node->locBackup;
2042  return true;
2043  }
2044  // location backup or first checksum is wrong, continue checking
2045 
2046  if (node->checksum == node->checksumBackup) {
2047  // it seems that location and location backup are wrong
2048  // or checksum value runs banana, not repairable
2049  return false;
2050  }
2051  // it seems that first checksum is wrong
2052  // try to fix with second checksum
2053 
2054  if (node->checksumBackup == calculateChecksum((unsigned char*)
2055  &(node->item->location), sizeof(volatile float*))) {
2056  // checksum backup tells, that first location should be valid, repair backup
2057  node->locBackup = node->item->location;
2058  // repair first checksum
2059  node->checksum = node->checksumBackup;
2060  return true;
2061  }
2062  // original location or second checksum is wrong, continue checking
2063 
2064  if (node->checksumBackup == calculateChecksum((unsigned char*)
2065  &(node->locBackup), sizeof(volatile float*))) {
2066  // checksum backup tells, that location backup should be valid, repair original
2067  node->item->location = node->locBackup;
2068  // repair checksum
2069  node->checksum = node->checksumBackup;
2070  return true;
2071  }
2072  // value is totally banana, no chance to fix
2073  return false;
2074 }
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: