--- libelwix/inc/elwix/acrc.h 2014/01/29 12:23:15 1.2.28.1 +++ libelwix/inc/elwix/acrc.h 2019/12/18 20:00:18 1.6.28.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: acrc.h,v 1.2.28.1 2014/01/29 12:23:15 misho Exp $ +* $Id: acrc.h,v 1.6.28.1 2019/12/18 20:00:18 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 +Copyright 2004 - 2019 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -64,7 +64,7 @@ typedef struct tagCRCPoly crcPoly_t; * * @crcNum = Number for reflection * @crcBits = Number width bits - * return: -1 error, !=-1 reflecting number + * return: reflecting number */ unsigned int crcReflect(unsigned int crcNum, unsigned char crcBits); /* @@ -76,26 +76,55 @@ unsigned int crcReflect(unsigned int crcNum, unsigned * @RevOpts = Options for computation (REVOPTS_REVERTBYTE, REVOPTS_REVERTCRC) * @initCRC = Initial CRC value * @xorCRC = Last xor CRC value - * return: -1 error, !=-1 CRC checksum + * return: CRC checksum */ unsigned int crcCalc(unsigned char * __restrict psBuf, unsigned int bufLen, unsigned char crcBits, unsigned char RevOpts, unsigned int initCRC, unsigned int xorCRC); /* + * crc16() - Checksum in X/Y modem communication + * + * @buf = Data for calculation + * @bufLen = Length of data + * return: Checksum + */ +unsigned short crc16(unsigned char * __restrict buf, int bufLen); +/* * crcIP() - Checksum in IP communication * * @buf = Data for calculation * @bufLen = Length of data - * return: -1 error, !=-1 Checksum + * return: Checksum */ unsigned short crcIP(unsigned char * __restrict buf, int bufLen); /* + * crcTCP() - Checksum for TCP v4 communication + * + * @buf = Data for calculation + * @bufLen = Length of data + * @th = TCP header + * return: Checksum + */ +unsigned short crcTCP(struct in_addr src, struct in_addr dst, + unsigned char * __restrict th); +/* + * crcUDP() - Checksum for UDP v4 communication + * + * @buf = Data for calculation + * @bufLen = Length of data + * @uh = UDP header + * return: Checksum + */ +unsigned short crcUDP(struct in_addr src, struct in_addr dst, + unsigned char * __restrict uh); + +/* * crcFletcher16() - Fletcher-16 Checksum computing * * @nBuf = Data for calculation * @bufLen = Length of data - * return: -1 error, !=-1 Checksum + * return: Checksum */ unsigned short crcFletcher16(unsigned short * __restrict nBuf, int bufLen); /* @@ -103,7 +132,7 @@ unsigned short crcFletcher16(unsigned short * __restri * * @nBuf = Data for calculation * @bufLen = Length of data - * return: -1 error, !=-1 Checksum + * return: Checksum */ unsigned int crcFletcher(unsigned short * __restrict nBuf, int bufLen); /* @@ -111,7 +140,7 @@ unsigned int crcFletcher(unsigned short * __restrict n * * @psBuf = Data for calculation * @bufLen = Length of data - * return: -1 error, !=-1 Checksum + * return: Checksum */ unsigned int crcAdler(unsigned char * __restrict psBuf, int bufLen); @@ -120,19 +149,19 @@ unsigned int crcAdler(unsigned char * __restrict psBuf * * @psBuf = Data for calculation * @bufLen = Length of data - * return: -1 error, !=-1 Checksum + * return: Checksum */ #define crcEther(psBuf, bufLen) crcCalc((psBuf), (bufLen), 32, 3, 0xFFFFFFFF, 0xFFFFFFFF) /* - * crc32() - CRC32 calculation from table + * crc_32() - CRC32 calculation from table * * @crc = Initial crc value * @buf = Data for calculation * @len = Length of data * return: calculated CRC32 */ -unsigned int crc32(unsigned int crc, const unsigned char * __restrict buf, unsigned int len); +unsigned int crc_32(unsigned int crc, const unsigned char * __restrict buf, unsigned int len); /* * crcPelco() - Calculate Pelco D/P CRC