User's Manual
DRAFT TrimTrac 1.5 Technical Manual v0.3ab 108
/*******************************************************************************
* Function: AppProtocolCalcTAIPChecksum
* Parameters: pszTAIPMsg, checksum
* Returns: Pointer to Checksum Header ;* if found, NULL otherwise.
* Description: This function checks for the presense of the TAIP checksum
* header. If it exists it calculates the checksum and
* places it in the checksum parameter and returns a pointer
* to the checksum header.
* Otherwise it returns NULL without changing checksum.
******************************************************************************/
char* AppProtocolCalcTAIPChecksum(char *pszTAIPMsg, unsigned char *checksum)
{
char *pcEnd;
char *pc;
unsigned char cs;
if((pcEnd = strstr(pszTAIPMsg, ";*")) != NULL) {
pc = pszTAIPMsg; // Start of the checsumed chars.
pcEnd += 2; // Move to the first non-checksumed char.
cs = 0;
while(pc < pcEnd) {
cs ^= *pc;
pc++;
}
*checksum = cs;
return pcEnd-2;
} else {
return NULL;
}
}
Table 45, Sample XOR Checksum Source Code