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

1.1       misho       1: /*
                      2:  * Copyright (C) 2005-2009 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 configuration_attribute configuration_attribute
                     19:  * @{ @ingroup payloads
                     20:  */
                     21: 
                     22: #ifndef CONFIGURATION_ATTRIBUTE_H_
                     23: #define CONFIGURATION_ATTRIBUTE_H_
                     24: 
                     25: typedef struct configuration_attribute_t configuration_attribute_t;
                     26: 
                     27: #include <library.h>
                     28: #include <attributes/attributes.h>
                     29: #include <encoding/payloads/payload.h>
                     30: 
                     31: /**
                     32:  * Class representing an IKEv2 configuration attribute / IKEv1 data attribute.
                     33:  */
                     34: struct configuration_attribute_t {
                     35: 
                     36:        /**
                     37:         * Implements payload_t interface.
                     38:         */
                     39:        payload_t payload_interface;
                     40: 
                     41:        /**
                     42:         * Get the type of the attribute.
                     43:         *
                     44:         * @return              type of the configuration attribute
                     45:         */
                     46:        configuration_attribute_type_t (*get_type)(configuration_attribute_t *this);
                     47: 
                     48:        /**
                     49:         * Returns the value of the attribute as chunk.
                     50:         *
                     51:         * @return              chunk_t pointing to the internal value
                     52:         */
                     53:        chunk_t (*get_chunk) (configuration_attribute_t *this);
                     54: 
                     55:        /**
                     56:         * Returns the 2 byte value of the attribute as u_int16.
                     57:         *
                     58:         * @return              attribute value
                     59:         */
                     60:        uint16_t (*get_value) (configuration_attribute_t *this);
                     61: 
                     62:        /**
                     63:         * Destroys an configuration_attribute_t object.
                     64:         */
                     65:        void (*destroy) (configuration_attribute_t *this);
                     66: };
                     67: 
                     68: /**
                     69:  * Creates an empty configuration attribute.
                     70:  *
                     71:  * @param type         PLV2_CONFIGURATION_ATTRIBUTE or PLV1_CONFIGURATION_ATTRIBUTE
                     72:  * @return                     created configuration attribute
                     73:  */
                     74: configuration_attribute_t *configuration_attribute_create(payload_type_t type);
                     75: 
                     76: /**
                     77:  * Creates a configuration attribute with type and value.
                     78:  *
                     79:  * @param type         PLV2_CONFIGURATION_ATTRIBUTE or PLV1_CONFIGURATION_ATTRIBUTE
                     80:  * @param attr_type    type of configuration attribute
                     81:  * @param chunk                attribute value, gets cloned
                     82:  * @return                     created configuration attribute
                     83:  */
                     84: configuration_attribute_t *configuration_attribute_create_chunk(
                     85:        payload_type_t type, configuration_attribute_type_t attr_type, chunk_t chunk);
                     86: 
                     87: /**
                     88:  * Creates a IKEv1 configuration attribute with 2 bytes value (IKEv1 only).
                     89:  *
                     90:  * @param attr_type    type of configuration attribute
                     91:  * @param value                attribute value, gets cloned
                     92:  * @return                     created PLV1_CONFIGURATION_ATTRIBUTE configuration attribute
                     93:  */
                     94: configuration_attribute_t *configuration_attribute_create_value(
                     95:                                        configuration_attribute_type_t attr_type, uint16_t value);
                     96: 
                     97: #endif /** CONFIGURATION_ATTRIBUTE_H_ @}*/

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