Diff for /libelwix/inc/elwix/acrc.h between versions 1.1 and 1.7

version 1.1, 2013/01/17 10:05:35 version 1.7, 2019/12/30 18:11:16
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013Copyright 2004 - 2019
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 64  typedef struct tagCRCPoly crcPoly_t; Line 64  typedef struct tagCRCPoly crcPoly_t;
  *   *
  * @crcNum = Number for reflection   * @crcNum = Number for reflection
  * @crcBits = Number width bits    * @crcBits = Number width bits 
 * return: -1 error, !=-1 reflecting number * return: reflecting number
  */   */
inline unsigned int crcReflect(unsigned int crcNum, unsigned char crcBits);unsigned int crcReflect(unsigned int crcNum, unsigned char crcBits);
 /*  /*
  * crcCalc() - Generic CRC calculation function for many sub variants of CRC algorithms   * crcCalc() - Generic CRC calculation function for many sub variants of CRC algorithms
  *   *
Line 76  inline unsigned int crcReflect(unsigned int crcNum, un Line 76  inline unsigned int crcReflect(unsigned int crcNum, un
  * @RevOpts = Options for computation (REVOPTS_REVERTBYTE, REVOPTS_REVERTCRC)   * @RevOpts = Options for computation (REVOPTS_REVERTBYTE, REVOPTS_REVERTCRC)
  * @initCRC = Initial CRC value   * @initCRC = Initial CRC value
  * @xorCRC = Last xor CRC value   * @xorCRC = Last xor CRC value
 * return: -1 error, !=-1 CRC checksum * return: CRC checksum
  */   */
inline unsigned int crcCalc(unsigned char * __restrict psBuf, unsigned int bufLen, unsigned int crcCalc(unsigned char * __restrict psBuf, unsigned int bufLen, 
                 unsigned char crcBits, unsigned char RevOpts,                   unsigned char crcBits, unsigned char RevOpts, 
                 unsigned int initCRC, unsigned int xorCRC);                  unsigned int initCRC, unsigned int xorCRC);
   
 /*  /*
    * crc16() - Checksum calculation in X/Y modem communication
    *
    * @buf = Data for calculation
    * @bufLen = Length of data
    * return: Checksum
    */
   unsigned short crc16(unsigned char * __restrict buf, int bufLen);
   /*
    * crc16_ext() - Checksum ver.2 calculation in X/Y modem communication
    *
    * @buf = Data for calculation
    * @bufLen = Length of data
    * return: Checksum
    */
   unsigned short crc16_ext(unsigned char * __restrict buf, int bufLen);
   /*
  * crcIP() - Checksum in IP communication   * crcIP() - Checksum in IP communication
  *   *
  * @buf = Data for calculation   * @buf = Data for calculation
  * @bufLen = Length of data   * @bufLen = Length of data
 * return: -1 error, !=-1 Checksum * return: Checksum
  */   */
inline unsigned short crcIP(unsigned char * __restrict buf, int bufLen);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   * crcFletcher16() - Fletcher-16 Checksum computing
  *   *
  * @nBuf = Data for calculation   * @nBuf = Data for calculation
  * @bufLen = Length of data   * @bufLen = Length of data
 * return: -1 error, !=-1 Checksum * return: Checksum
  */   */
inline unsigned short crcFletcher16(unsigned short * __restrict nBuf, int bufLen);unsigned short crcFletcher16(unsigned short * __restrict nBuf, int bufLen);
 /*  /*
  * crcFletcher() - Fletcher-32 Checksum computing   * crcFletcher() - Fletcher-32 Checksum computing
  *   *
  * @nBuf = Data for calculation   * @nBuf = Data for calculation
  * @bufLen = Length of data   * @bufLen = Length of data
 * return: -1 error, !=-1 Checksum * return: Checksum
  */   */
inline unsigned int crcFletcher(unsigned short * __restrict nBuf, int bufLen);unsigned int crcFletcher(unsigned short * __restrict nBuf, int bufLen);
 /*  /*
  * crcAdler() - crcAdler-32 Checksum computing   * crcAdler() - crcAdler-32 Checksum computing
  *   *
  * @psBuf = Data for calculation   * @psBuf = Data for calculation
  * @bufLen = Length of data   * @bufLen = Length of data
 * return: -1 error, !=-1 Checksum * return: Checksum
  */   */
inline unsigned int crcAdler(unsigned char * __restrict psBuf, int bufLen);unsigned int crcAdler(unsigned char * __restrict psBuf, int bufLen);
   
 /*  /*
  * crcEther() - Checksum in Ethernet communication   * crcEther() - Checksum in Ethernet communication
  *   *
  * @psBuf = Data for calculation   * @psBuf = Data for calculation
  * @bufLen = Length of data   * @bufLen = Length of data
 * return: -1 error, !=-1 Checksum * return: Checksum
  */   */
 #define crcEther(psBuf, bufLen) crcCalc((psBuf), (bufLen), 32, 3, 0xFFFFFFFF, 0xFFFFFFFF)  #define crcEther(psBuf, bufLen) crcCalc((psBuf), (bufLen), 32, 3, 0xFFFFFFFF, 0xFFFFFFFF)
   
   /*
    * crc_32() - CRC32 calculation from table
    *
    * @crc = Initial crc value
    * @buf = Data for calculation
    * @len = Length of data
    * return: calculated CRC32
    */
   unsigned int crc_32(unsigned int crc, const unsigned char * __restrict buf, unsigned int len);
   
 /*  /*
  * crcPelco() - Calculate Pelco D/P CRC   * crcPelco() - Calculate Pelco D/P CRC
Line 133  inline unsigned int crcAdler(unsigned char * __restric Line 179  inline unsigned int crcAdler(unsigned char * __restric
  * return: crc for packet, if is 0 check and crc_GetErrno() == 1    * return: crc for packet, if is 0 check and crc_GetErrno() == 1 
         Pelco protocol not supported          Pelco protocol not supported
  */   */
inline unsigned char crcPelco(unsigned char ver, unsigned char *pkt);unsigned char crcPelco(unsigned char ver, unsigned char *pkt);
   
   
 /*  /*
Line 144  inline unsigned char crcPelco(unsigned char ver, unsig Line 190  inline unsigned char crcPelco(unsigned char ver, unsig
  * @nVer = Version of algorythm; 0 - original, 1 - AITNET variant   * @nVer = Version of algorythm; 0 - original, 1 - AITNET variant
  * return: Hash value   * return: Hash value
 */  */
inline unsigned int hash_varchar(const char *csStr, int nStrLen, int nVer);unsigned int hash_varchar(const char *csStr, int nStrLen, int nVer);
 /*  /*
  * hash_bernstein() - Compute index hash by Bernstein   * hash_bernstein() - Compute index hash by Bernstein
  *   *
Line 153  inline unsigned int hash_varchar(const char *csStr, in Line 199  inline unsigned int hash_varchar(const char *csStr, in
  * @nVer = Version of algorythm; 0 - Bernstein, 1 - DJBX33A variant   * @nVer = Version of algorythm; 0 - Bernstein, 1 - DJBX33A variant
  * return: Hash value   * return: Hash value
 */  */
inline unsigned int hash_bernstein(const char *csStr, int nStrLen, int nVer);unsigned int hash_bernstein(const char *csStr, int nStrLen, int nVer);
 /*  /*
  * hash_jenkins() - Compute index hash by Jenkins (one-at-a-time)   * hash_jenkins() - Compute index hash by Jenkins (one-at-a-time)
  *   *
Line 161  inline unsigned int hash_bernstein(const char *csStr,  Line 207  inline unsigned int hash_bernstein(const char *csStr, 
  * @nStrLen = Length of data buffer   * @nStrLen = Length of data buffer
  * return: Hash value   * return: Hash value
 */  */
inline unsigned int hash_jenkins(const char *csStr, int nStrLen);unsigned int hash_jenkins(const char *csStr, int nStrLen);
 /*  /*
  * hash_jenkins32() - Fast Jenkins hash function   * hash_jenkins32() - Fast Jenkins hash function
  *   *
Line 178  unsigned int hash_jenkins32(const unsigned int *buf, i Line 224  unsigned int hash_jenkins32(const unsigned int *buf, i
  * @nStrLen = Length of data buffer   * @nStrLen = Length of data buffer
  * return: Hash value   * return: Hash value
 */  */
inline unsigned int hash_reddragon(const char *csStr, int nStrLen);unsigned int hash_reddragon(const char *csStr, int nStrLen);
 /*  /*
  * hash_fnv1() - Compute index hash by FNV-1   * hash_fnv1() - Compute index hash by FNV-1
  *   *
Line 187  inline unsigned int hash_reddragon(const char *csStr,  Line 233  inline unsigned int hash_reddragon(const char *csStr, 
  * @nVer = Version of algorythm; 0 - FNV-1, 1 - FNV-1a (best avalanche)   * @nVer = Version of algorythm; 0 - FNV-1, 1 - FNV-1a (best avalanche)
  * return: Hash value   * return: Hash value
 */  */
inline unsigned int hash_fnv1(const char *csStr, int nStrLen, int nVer);unsigned int hash_fnv1(const char *csStr, int nStrLen, int nVer);
   
 /*  /*
  * hash_fnv() - Compute index hash by FNV-1a   * hash_fnv() - Compute index hash by FNV-1a

Removed from v.1.1  
changed lines
  Added in v.1.7


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>