Annotation of embedaddon/strongswan/src/libstrongswan/plugins/bliss/bliss_bitpacker.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2014 Andreas Steffen
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             4:  *
        !             5:  * This program is free software; you can redistribute it and/or modify it
        !             6:  * under the terms of the GNU General Public License as published by the
        !             7:  * Free Software Foundation; either version 2 of the License, or (at your
        !             8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !             9:  *
        !            10:  * This program is distributed in the hope that it will be useful, but
        !            11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            13:  * for more details.
        !            14:  */
        !            15: 
        !            16: /**
        !            17:  * @defgroup bliss_bitpacker bliss_bitpacker
        !            18:  * @{ @ingroup bliss_p
        !            19:  */
        !            20: 
        !            21: #ifndef BLISS_BITPACKER_H_
        !            22: #define BLISS_BITPACKER_H_
        !            23: 
        !            24: #include <library.h>
        !            25: 
        !            26: typedef struct bliss_bitpacker_t bliss_bitpacker_t;
        !            27: 
        !            28: /**
        !            29:  * Reads and writes a variable number of bits in packed format
        !            30:  * from and to an octet buffer
        !            31:  */
        !            32: struct bliss_bitpacker_t {
        !            33: 
        !            34:        /**
        !            35:         * Get the number of bits written into buffer
        !            36:         *
        !            37:         * @result                      Number of bits written
        !            38:         */
        !            39:        size_t (*get_bits)(bliss_bitpacker_t *this);
        !            40: 
        !            41:        /**
        !            42:         * Get the prime modulus of the Number Theoretic Transform
        !            43:         *
        !            44:         * @param value         Value to be written
        !            45:         * @param bits          Number of bits to be written
        !            46:         * @result                      TRUE if value could be written into buffer
        !            47:         */
        !            48:        bool (*write_bits)(bliss_bitpacker_t *this, uint32_t value, size_t bits);
        !            49: 
        !            50: 
        !            51:        /**
        !            52:         * Get the prime modulus of the Number Theoretic Transform
        !            53:         *
        !            54:         * @param value         Value returned
        !            55:         * @param bits          Number of bits to be read
        !            56:         * @result                      TRUE if value could be read from buffer
        !            57:         */
        !            58:        bool (*read_bits)(bliss_bitpacker_t *this, uint32_t *value, size_t bits);
        !            59: 
        !            60:        /**
        !            61:         * Detach the internal octet buffer and return it
        !            62:         */
        !            63:        chunk_t (*extract_buf)(bliss_bitpacker_t *this);
        !            64: 
        !            65:        /**
        !            66:         * Destroy bliss_bitpacker_t object
        !            67:         */
        !            68:        void (*destroy)(bliss_bitpacker_t *this);
        !            69: };
        !            70: 
        !            71: /**
        !            72:  * Create a bliss_bitpacker_t object for writing
        !            73:  *
        !            74:  * @param max_bits             Total number of bits to be stored
        !            75:  */
        !            76: bliss_bitpacker_t* bliss_bitpacker_create(uint16_t max_bits);
        !            77: 
        !            78: /**
        !            79:  * Create a bliss_bitpacker_t object for reading
        !            80:  *
        !            81:  * @param data                 Packed array of bits
        !            82:  */
        !            83: bliss_bitpacker_t* bliss_bitpacker_create_from_data(chunk_t data);
        !            84: 
        !            85: #endif /** BLISS_BITPACKER_H_ @}*/

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