Annotation of libaitcrc/inc/aitcrc.h, revision 1.1.1.1.2.1
1.1 misho 1: /*************************************************************************
2: * (C) 2008 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
3: * by Michael Pounov <misho@openbsd-bg.org>
4: *
5: * $Author: misho $
1.1.1.1.2.1! misho 6: * $Id: aitcrc.h,v 1.1.1.1 2008/11/05 17:02:55 misho Exp $
1.1 misho 7: *
8: *************************************************************************/
9: #ifndef __AITCRC_H
10: #define __AITCRC_H
11:
12:
1.1.1.1.2.1! misho 13: #include <sys/types.h>
! 14:
! 15:
1.1 misho 16: #define REVOPTS_REVERTBYTE 1
17: #define REVOPTS_REVERTCRC 2
18:
19:
20: struct tagCRCPoly {
21: u_char poly_bits;
22: u_long poly_num;
23: char poly_name[19];
24: }; // size 24bytes
25: typedef struct tagCRCPoly crcPoly_t;
26:
27:
1.1.1.1.2.1! misho 28: // -------------------------------------------------------
! 29: // crc_GetErrno() Get error code of last operation
1.1 misho 30: inline int crc_GetErrno();
1.1.1.1.2.1! misho 31: // crc_GetError() Get error text of last operation
1.1 misho 32: inline const char *crc_GetError();
1.1.1.1.2.1! misho 33: // -------------------------------------------------------
1.1 misho 34:
1.1.1.1.2.1! misho 35: /*
! 36: * crcReflect() Reflect all bits of number
! 37: * @crcNum = Number for reflection
! 38: * @crcBits = Number width bits
! 39: * return: -1 error, !=-1 reflecting number
! 40: */
1.1 misho 41: inline u_long crcReflect(u_long crcNum, u_char crcBits);
1.1.1.1.2.1! misho 42: /*
! 43: * crcCalc() Generic CRC calculation function for many sub variants of CRC algorithms
! 44: * @psBuf = Data for calculation
! 45: * @bufLen = Length of data
! 46: * @crcBits = CRC algorithm bits (1, 4, 5, 6, 7, 8, 10, 11, 12, 15, 16, 24, 30, 32)
! 47: * @RevOpts = Options for computation (REVOPTS_REVERTBYTE, REVOPTS_REVERTCRC)
! 48: * @initCRC = Initial CRC value
! 49: * @xorCRC = Last xor CRC value
! 50: * return: -1 error, !=-1 CRC checksum
! 51: */
1.1 misho 52: inline u_long crcCalc(u_char * __restrict psBuf, u_int bufLen, u_char crcBits, u_char RevOpts, u_long initCRC, u_long xorCRC);
53:
1.1.1.1.2.1! misho 54: /*
! 55: * crcIP() Checksum in IP communication
! 56: * @nBuf = Data for calculation
! 57: * @bufLen = Length of data
! 58: * return: -1 error, !=-1 Checksum
! 59: */
1.1 misho 60: inline u_short crcIP(u_short * __restrict nBuf, int bufLen);
1.1.1.1.2.1! misho 61: /*
! 62: * crcFletcher() Fletcher-16 Checksum computing
! 63: * @nBuf = Data for calculation
! 64: * @bufLen = Length of data
! 65: * return: -1 error, !=-1 Checksum
! 66: */
1.1 misho 67: inline u_long crcFletcher(u_short * __restrict nBuf, int bufLen);
1.1.1.1.2.1! misho 68: /*
! 69: * crcAdler() crcAdler-32 Checksum computing
! 70: * @psBuf = Data for calculation
! 71: * @bufLen = Length of data
! 72: * return: -1 error, !=-1 Checksum
! 73: */
1.1 misho 74: inline u_long crcAdler(u_char * __restrict psBuf, int bufLen);
75:
1.1.1.1.2.1! misho 76: /*
! 77: * crcEther() Checksum in Ethernet communication
! 78: * @psBuf = Data for calculation
! 79: * @bufLen = Length of data
! 80: * return: -1 error, !=-1 Checksum
! 81: */
1.1 misho 82: #define crcEther(psBuf, bufLen) crcCalc((psBuf), (bufLen), 32, 3, 0xFFFFFFFF, 0xFFFFFFFF)
83:
84:
85: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>