Go to the source code of this file.
Functions | |
| unsigned long | rdxsum_calc (const long *ptr, char version) |
| void | rdxsum_fill (long *ptr, char version) |
| int | rdxsum_test (const long *ptr) |
|
||||||||||||
|
Definition at line 27 of file rdChecksum.c. Referenced by append_dcs_alarm_block(), append_dcs_header_block(), append_dcs_monitor_block(), dump_one_record(), rdxsum_fill(), rdxsum_test(), and send_bogus_stuff(). 00028 {
00029 unsigned long sum = 0;
00030 const long *begin = ptr + 2; /* contiguous data starts here */
00031 const long *end = ptr + (*ptr); /* this is one word too far */
00032 int v2 = version & 0x3;
00033
00034 /* protect against null pointers */
00035 if (!ptr) return 0;
00036
00037 /*
00038 * By reserving 2 bits at the top we can support 4 possible
00039 * checksum algorithms, in case we wish to switch at a later
00040 * time, while still retaining the ability to know which
00041 * algorithm was used. Until all are implemented, cascade
00042 * downward until an existing one is found.
00043 */
00044 switch (v2) {
00045 case 0x3:
00046 v2 = 0x3; /* tag with what we used, not requested */
00047 /* break; */ /* this version not supported: fall through */
00048 case 0x2:
00049 v2 = 0x2; /* tag with what we used, not requested */
00050 /* break; */ /* this version not supported: fall through */
00051 case 0x1:
00052 v2 = 0x1 ; /* tag with what we used, not requested */
00053 /* --- add next algorithm here, make break "active" */
00054 /* break; */ /* this version not supported: fall through */
00055 case 0x0:
00056 default:
00057 /* the "0" and default algorithm is very simple ... */
00058 /* simply add up everything ignoring overflows */
00059
00060 v2 = 0x0; /* tag with what we used, not requested */
00061 sum = *ptr; /* prime the pump with the word count */
00062 while (begin<end) sum += *begin++;
00063 }
00064 /* remove top two bits and replace them with the version */
00065 return (sum & 0x3fffffff) | ( version << 30 );
00066 }
|
|
||||||||||||
|
|
Definition at line 105 of file rdChecksum.c. References rdxsum_calc(). Referenced by dump_one_record(), and RawDataBlock::TestChecksum(). 00106 {
00107 unsigned long stored;
00108 int version;
00109
00110 /* protect against null pointers */
00111 if (!ptr) return 1;
00112
00113 stored = *(ptr+1);
00114 version = ( 0x3 & ( stored >> 30 ) );
00115 return stored != rdxsum_calc(ptr,version);
00116 }
|
1.3.9.1