/* Calculates the appropriate TCP checksum, consisting of the addition of the one's compliment of each word, complimented. */
static uint16_t TCP_Checksum16(void *TCPHeaderOutStart, const IP_Address_t *SourceAddress, const IP_Address_t *DestinationAddress, uint16_t TCPOutSize)
/* Calculates the appropriate TCP checksum, consisting of the addition of the one's compliment of each word, complimented. */
static uint16_t TCP_Checksum16(void *TCPHeaderOutStart, const IP_Address_t *SourceAddress, const IP_Address_t *DestinationAddress, uint16_t TCPOutSize)
{
	uint32_t Checksum = 0;
	Checksum += ((uint16_t*)SourceAddress)[0];
	Checksum += ((uint16_t*)SourceAddress)[1];
	Checksum += ((uint16_t*)DestinationAddress)[0];
	Checksum += ((uint16_t*)DestinationAddress)[1];
	Checksum += SwapEndian_16(PROTOCOL_TCP);
	Checksum += SwapEndian_16(TCPOutSize);
	for (uint16_t CurrWord = 0; CurrWord < (TCPOutSize >> 1); CurrWord++)
	  Checksum += ((uint16_t*)TCPHeaderOutStart)[CurrWord];
	if (TCPOutSize & 0x01)
	  Checksum += (((uint16_t*)TCPHeaderOutStart)[TCPOutSize >> 1] & 0x00FF);
	while (Checksum & 0xFFFF0000)
	  Checksum = ((Checksum & 0xFFFF) + (Checksum >> 16));
	return ~Checksum;
}