Annotation of embedaddon/strongswan/src/libimcv/seg/seg_contract.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2014-2015 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 seg_contract seg_contract
        !            18:  * @{ @ingroup libimcv_seg
        !            19:  */
        !            20: 
        !            21: #ifndef SEG_CONTRACT_H_
        !            22: #define SEG_CONTRACT_H_
        !            23: 
        !            24: typedef struct seg_contract_t seg_contract_t;
        !            25: 
        !            26: #include "pa_tnc/pa_tnc_attr.h"
        !            27: 
        !            28: #include <library.h>
        !            29: #include <pen/pen.h>
        !            30: 
        !            31: #include <tncif.h>
        !            32: 
        !            33: #define SEG_CONTRACT_MAX_SIZE_VALUE            0xffffffff
        !            34: #define SEG_CONTRACT_NO_FRAGMENTATION  SEG_CONTRACT_MAX_SIZE_VALUE
        !            35: 
        !            36: /**
        !            37:  * Interface for a PA-TNC attribute segmentation contract
        !            38:  *
        !            39:  */
        !            40: struct seg_contract_t {
        !            41: 
        !            42:        /**
        !            43:         * Get the PA-TNC message type.
        !            44:         *
        !            45:         * @return                                      PA-TNC Message type
        !            46:         */
        !            47:        pen_type_t (*get_msg_type)(seg_contract_t *this);
        !            48: 
        !            49:        /**
        !            50:         * Set maximum PA-TNC attribute and segment size in octets
        !            51:         *
        !            52:         * @param max_attr_size Maximum PA-TNC attribute size in octets
        !            53:         * @param max_seg_size  Maximum PA-TNC attribute segment size in octets
        !            54:         */
        !            55:        void (*set_max_size)(seg_contract_t *this, uint32_t max_attr_size,
        !            56:                                                                                           uint32_t max_seg_size);
        !            57: 
        !            58:        /**
        !            59:         * Get maximum PA-TNC attribute and segment size in octets
        !            60:         *
        !            61:         * @param max_attr_size Maximum PA-TNC attribute size in octets
        !            62:         * @param max_seg_size  Maximum PA-TNC attribute segment size in octets
        !            63:         */
        !            64:        void (*get_max_size)(seg_contract_t *this, uint32_t *max_attr_size,
        !            65:                                                                                           uint32_t *max_seg_size);
        !            66: 
        !            67:        /**
        !            68:         * Check if a PA-TNC attribute must be segmented or is oversized
        !            69:         *
        !            70:         * @param attr                  PA-TNC attribute to be checked
        !            71:         * @param oversize              PA-TNC attribute is larger than maximum size
        !            72:         * @return                              TRUE if PA-TNC attribute must be segmented
        !            73:         */
        !            74:        bool (*check_size)(seg_contract_t *this, pa_tnc_attr_t *attr,
        !            75:                                                                                         bool *oversize);
        !            76: 
        !            77:        /**
        !            78:         * Generate first segment of a PA-TNC attribute according to the contract
        !            79:         *
        !            80:         * @param attr                  PA-TNC attribute to be segmented
        !            81:         * @param max_attr_len  Maximum size of first segment envelope attribute
        !            82:         * @return                              First segment envelope attribute
        !            83:         */
        !            84:        pa_tnc_attr_t* (*first_segment)(seg_contract_t *this, pa_tnc_attr_t *attr,
        !            85:                                                                        size_t max_attr_len);
        !            86: 
        !            87:        /**
        !            88:         * Generate next segment of a PA-TNC attribute according to the contract
        !            89:         *
        !            90:         * @param base_attr_id  Base Attribute ID
        !            91:         * @return                              Next segment envelope attribute
        !            92:         */
        !            93:        pa_tnc_attr_t* (*next_segment)(seg_contract_t *this, uint32_t base_attr_id);
        !            94: 
        !            95:        /**
        !            96:         * Add an attribute segments until the PA-TNC attribute is reconstructed
        !            97:         *
        !            98:         * @param attr                  Segment envelope attribute
        !            99:         * @param error                 Error attribute if an error occurred or NULL
        !           100:         * @param more                  Need more segments
        !           101:         * @return                              Completed PA-TNC attribute or NULL
        !           102:         */
        !           103:        pa_tnc_attr_t* (*add_segment)(seg_contract_t *this,
        !           104:                                                                 pa_tnc_attr_t *attr, pa_tnc_attr_t **error,
        !           105:                                                                 bool *more);
        !           106: 
        !           107:        /**
        !           108:         * Get contract role
        !           109:         *
        !           110:         * @return                              TRUE:  contracting party (issuer),
        !           111:         *                                              FALSE: contracted party
        !           112:         */
        !           113:        bool (*is_issuer)(seg_contract_t *this);
        !           114: 
        !           115:        /**
        !           116:         * Is this a null contract ?
        !           117:         *
        !           118:         * @return                              TRUE if null contract
        !           119:         */
        !           120:        bool (*is_null)(seg_contract_t *this);
        !           121: 
        !           122:        /**
        !           123:         * Set the responder ID
        !           124:         *
        !           125:         * @param responder             IMC or IMV ID of responder
        !           126:         */
        !           127:        void (*set_responder)(seg_contract_t *this, TNC_UInt32 responder);
        !           128: 
        !           129:        /**
        !           130:         * Get the responder ID
        !           131:         *
        !           132:         * @return                              IMC or IMV ID of responder
        !           133:         */
        !           134:        TNC_UInt32 (*get_responder)(seg_contract_t *this);
        !           135: 
        !           136:        /**
        !           137:         * Get the issuer ID
        !           138:         *
        !           139:         * @return                              IMC or IMV ID of issuer
        !           140:         */
        !           141:        TNC_UInt32 (*get_issuer)(seg_contract_t *this);
        !           142: 
        !           143:        /**
        !           144:         * Clone a contract
        !           145:         *
        !           146:         * @return                              Cloned contract
        !           147:         */
        !           148:        seg_contract_t* (*clone)(seg_contract_t *this);
        !           149: 
        !           150:        /**
        !           151:         * Get an info string about the contract
        !           152:         *
        !           153:         * @param buf                   String buffer of at least size len
        !           154:         * @param len                   Size of string buffer
        !           155:         * @param request               TRUE if contract request, FALSE if response
        !           156:         */
        !           157:        void (*get_info_string)(seg_contract_t *this, char *buf, size_t len,
        !           158:                                                        bool request);
        !           159: 
        !           160:        /**
        !           161:         * Destroys a seg_contract_t object.
        !           162:         */
        !           163:        void (*destroy)(seg_contract_t *this);
        !           164: };
        !           165: 
        !           166: /**
        !           167:  * Create a PA-TNC attribute segmentation contract
        !           168:  *
        !           169:  * @param msg_type                     PA-TNC message type
        !           170:  * @param max_attr_size                Maximum PA-TNC attribute size in octets
        !           171:  * @param max_seg_size         Maximum PA-TNC attribute segment size in octets
        !           172:  * @param is_issuer                    TRUE if issuer of the contract
        !           173:  * @param issuer_id                    IMC or IMV ID of issuer
        !           174:  * @param is_imc                       TRUE if IMC, FALSE if IMV
        !           175:  */
        !           176: seg_contract_t* seg_contract_create(pen_type_t msg_type,
        !           177:                                                                        uint32_t max_attr_size,
        !           178:                                                                        uint32_t max_seg_size,
        !           179:                                                                        bool is_issuer, TNC_UInt32 issuer_id,
        !           180:                                                                        bool is_imc);
        !           181: 
        !           182: #endif /** SEG_CONTRACT_H_ @}*/

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