Annotation of embedaddon/strongswan/src/libcharon/encoding/payloads/transform_attribute.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2005-2006 Martin Willi
                      3:  * Copyright (C) 2005 Jan Hutter
                      4:  * HSR Hochschule fuer Technik Rapperswil
                      5:  *
                      6:  * This program is free software; you can redistribute it and/or modify it
                      7:  * under the terms of the GNU General Public License as published by the
                      8:  * Free Software Foundation; either version 2 of the License, or (at your
                      9:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
                     10:  *
                     11:  * This program is distributed in the hope that it will be useful, but
                     12:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     13:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
                     14:  * for more details.
                     15:  */
                     16: 
                     17: /**
                     18:  * @defgroup transform_attribute transform_attribute
                     19:  * @{ @ingroup payloads
                     20:  */
                     21: 
                     22: #ifndef TRANSFORM_ATTRIBUTE_H_
                     23: #define TRANSFORM_ATTRIBUTE_H_
                     24: 
                     25: typedef enum transform_attribute_type_t transform_attribute_type_t;
                     26: typedef struct transform_attribute_t transform_attribute_t;
                     27: 
                     28: #include <library.h>
                     29: #include <encoding/payloads/payload.h>
                     30: 
                     31: /**
                     32:  * Type of the attribute.
                     33:  */
                     34: enum transform_attribute_type_t {
                     35:        /** IKEv1 Phase 1 attributes */
                     36:        TATTR_PH1_ENCRYPTION_ALGORITHM = 1,
                     37:        TATTR_PH1_HASH_ALGORITHM = 2,
                     38:        TATTR_PH1_AUTH_METHOD = 3,
                     39:        TATTR_PH1_GROUP = 4,
                     40:        TATTR_PH1_GROUP_TYPE = 5,
                     41:        TATTR_PH1_GROUP_PRIME = 6,
                     42:        TATTR_PH1_GROUP_GENONE = 7,
                     43:        TATTR_PH1_GROUP_GENTWO = 8,
                     44:        TATTR_PH1_GROUP_CURVE_A = 9,
                     45:        TATTR_PH1_GROUP_CURVE_B = 10,
                     46:        TATTR_PH1_LIFE_TYPE = 11,
                     47:        TATTR_PH1_LIFE_DURATION = 12,
                     48:        TATTR_PH1_PRF = 13,
                     49:        TATTR_PH1_KEY_LENGTH = 14,
                     50:        TATTR_PH1_FIELD_SIZE = 15,
                     51:        TATTR_PH1_GROUP_ORDER = 16,
                     52:        /** IKEv1 Phase 2 attributes */
                     53:        TATTR_PH2_SA_LIFE_TYPE = 1,
                     54:        TATTR_PH2_SA_LIFE_DURATION = 2,
                     55:        TATTR_PH2_GROUP = 3,
                     56:        TATTR_PH2_ENCAP_MODE = 4,
                     57:        TATTR_PH2_AUTH_ALGORITHM = 5,
                     58:        TATTR_PH2_KEY_LENGTH = 6,
                     59:        TATTR_PH2_KEY_ROUNDS = 7,
                     60:        TATTR_PH2_COMP_DICT_SIZE = 8,
                     61:        TATTR_PH2_COMP_PRIV_ALGORITHM = 9,
                     62:        TATTR_PH2_ECN_TUNNEL = 10,
                     63:        TATTR_PH2_EXT_SEQ_NUMBER = 11,
                     64:        /* IKEv2 key length attribute */
                     65:        TATTR_IKEV2_KEY_LENGTH = 14,
                     66:        /* undefined, private use attribute */
                     67:        TATTR_UNDEFINED = 16384,
                     68: };
                     69: 
                     70: /**
                     71:  * Enum names for IKEv1 Phase 1 transform_attribute_type_t.
                     72:  */
                     73: extern enum_name_t *tattr_ph1_names;
                     74: 
                     75: /**
                     76:  * Enum names for IKEv1 Phase 2 transform_attribute_type_t.
                     77:  */
                     78: extern enum_name_t *tattr_ph2_names;
                     79: 
                     80: /**
                     81:  * Enum names for IKEv2 transform_attribute_type_t.
                     82:  */
                     83: extern enum_name_t *tattr_ikev2_names;
                     84: 
                     85: 
                     86: /**
                     87:  * Class representing an IKEv1/IKEv2 TRANSFORM Attribute.
                     88:  */
                     89: struct transform_attribute_t {
                     90: 
                     91:        /**
                     92:         * The payload_t interface.
                     93:         */
                     94:        payload_t payload_interface;
                     95: 
                     96:        /**
                     97:         * Returns the currently set value of the attribute.
                     98:         *
                     99:         * Returned data are not copied.
                    100:         *
                    101:         * @return              chunk_t pointing to internal value
                    102:         */
                    103:        chunk_t (*get_value_chunk) (transform_attribute_t *this);
                    104: 
                    105:        /**
                    106:         * Returns the currently set value of the attribute.
                    107:         *
                    108:         * Returned data are not copied.
                    109:         *
                    110:         * @return              value
                    111:         */
                    112:        uint64_t (*get_value) (transform_attribute_t *this);
                    113: 
                    114:        /**
                    115:         * get the type of the attribute.
                    116:         *
                    117:         * @return              type of the value
                    118:         */
                    119:        uint16_t (*get_attribute_type) (transform_attribute_t *this);
                    120: 
                    121:        /**
                    122:         * Destroys an transform_attribute_t object.
                    123:         */
                    124:        void (*destroy) (transform_attribute_t *this);
                    125: };
                    126: 
                    127: /**
                    128:  * Creates an empty transform_attribute_t object.
                    129:  *
                    130:  * @param type                 PLV2_TRANSFORM_ATTRIBUTE or PLV1_TRANSFORM_ATTRIBUTE
                    131:  * @return                             transform_attribute_t object
                    132:  */
                    133: transform_attribute_t *transform_attribute_create(payload_type_t type);
                    134: 
                    135: /**
                    136:  * Creates a two byte value or a larger attribute for a given attribute kind.
                    137:  *
                    138:  * @param type                 PLV2_TRANSFORM_ATTRIBUTE or PLV1_TRANSFORM_ATTRIBUTE
                    139:  * @param kind                 attribute kind
                    140:  * @param value                        fixed two byte value
                    141:  * @return                             transform_attribute_t object
                    142:  */
                    143: transform_attribute_t *transform_attribute_create_value(payload_type_t type,
                    144:                                                        transform_attribute_type_t kind, uint64_t value);
                    145: 
                    146: #endif /** TRANSFORM_ATTRIBUTE_H_ @}*/

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