Annotation of libaitcrc/inc/aitcrc.h, revision 1.2

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.2     ! misho       6: * $Id: aitcrc.h,v 1.1.1.1.2.1 2008/11/05 17:29:19 misho Exp $
1.1       misho       7: *
                      8: *************************************************************************/
                      9: #ifndef __AITCRC_H
                     10: #define __AITCRC_H
                     11: 
                     12: 
1.2     ! 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.2     ! misho      28: // -------------------------------------------------------
        !            29: // crc_GetErrno() Get error code of last operation
1.1       misho      30: inline int crc_GetErrno();
1.2     ! misho      31: // crc_GetError() Get error text of last operation
1.1       misho      32: inline const char *crc_GetError();
1.2     ! misho      33: // -------------------------------------------------------
1.1       misho      34: 
1.2     ! 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.2     ! 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.2     ! 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.2     ! 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.2     ! 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.2     ! 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: 
1.2     ! misho      84: /*
        !            85:  * crcPelco() Calculate Pelco D/P CRC
        !            86:  * @ver = Pelco protocol version (Dd | Pp)
        !            87:  * @pkt = Packet for calculate crc
        !            88:  * return: crc for packet, if is 0 check and crc_GetErrno() == 1 
        !            89:        Pelco protocol not supported
        !            90:  */
        !            91: inline u_char crcPelco(u_char ver, u_char *pkt);
        !            92: 
1.1       misho      93: 
                     94: #endif

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