Annotation of embedaddon/strongswan/src/libcharon/attributes/attribute_manager.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2008-2009 Martin Willi
        !             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 attribute_manager attribute_manager
        !            18:  * @{ @ingroup attributes
        !            19:  */
        !            20: 
        !            21: #ifndef ATTRIBUTE_MANAGER_H_
        !            22: #define ATTRIBUTE_MANAGER_H_
        !            23: 
        !            24: #include "attribute_provider.h"
        !            25: #include "attribute_handler.h"
        !            26: 
        !            27: #include <sa/ike_sa.h>
        !            28: 
        !            29: typedef struct attribute_manager_t attribute_manager_t;
        !            30: 
        !            31: /**
        !            32:  * The attribute manager hands out attributes or handles them.
        !            33:  *
        !            34:  * The attribute manager manages both, attribute providers and attribute
        !            35:  * handlers. Attribute providers are responsible to hand out attributes if
        !            36:  * a connecting peer requests them. Handlers handle such attributes if they
        !            37:  * are received on the requesting peer.
        !            38:  */
        !            39: struct attribute_manager_t {
        !            40: 
        !            41:        /**
        !            42:         * Acquire a virtual IP address to assign to a peer.
        !            43:         *
        !            44:         * @param pools                 list of pool names (char*) to acquire from
        !            45:         * @param ike_sa                associated IKE_SA for which an address is requested
        !            46:         * @param requested             IP in configuration request
        !            47:         * @return                              allocated address, NULL to serve none
        !            48:         */
        !            49:        host_t* (*acquire_address)(attribute_manager_t *this,
        !            50:                                                           linked_list_t *pool, ike_sa_t *ike_sa,
        !            51:                                                           host_t *requested);
        !            52: 
        !            53:        /**
        !            54:         * Release a previously acquired address.
        !            55:         *
        !            56:         * @param pools                 list of pool names (char*) to release to
        !            57:         * @param address               address to release
        !            58:         * @param ike_sa                associated IKE_SA for which an address is released
        !            59:         * @return                              TRUE if address released to pool
        !            60:         */
        !            61:        bool (*release_address)(attribute_manager_t *this,
        !            62:                                                        linked_list_t *pools, host_t *address,
        !            63:                                                        ike_sa_t *ike_sa);
        !            64: 
        !            65:        /**
        !            66:         * Create an enumerator over attributes to hand out to a peer.
        !            67:         *
        !            68:         * @param pool                  list of pools names (char*) to query attributes from
        !            69:         * @param ike_sa                associated IKE_SA for which attributes are requested
        !            70:         * @param vip                   list of virtual IPs (host_t*) to assign to peer
        !            71:         * @return                              enumerator (configuration_attribute_type_t, chunk_t)
        !            72:         */
        !            73:        enumerator_t* (*create_responder_enumerator)(attribute_manager_t *this,
        !            74:                                                                        linked_list_t *pool, ike_sa_t *ike_sa,
        !            75:                                                                        linked_list_t *vips);
        !            76: 
        !            77:        /**
        !            78:         * Register an attribute provider to the manager.
        !            79:         *
        !            80:         * @param provider              attribute provider to register
        !            81:         */
        !            82:        void (*add_provider)(attribute_manager_t *this,
        !            83:                                                 attribute_provider_t *provider);
        !            84:        /**
        !            85:         * Unregister an attribute provider from the manager.
        !            86:         *
        !            87:         * @param provider              attribute provider to unregister
        !            88:         */
        !            89:        void (*remove_provider)(attribute_manager_t *this,
        !            90:                                                        attribute_provider_t *provider);
        !            91: 
        !            92:        /**
        !            93:         * Handle a configuration attribute by passing them to the handlers.
        !            94:         *
        !            95:         * @param ike_sa                associated IKE_SA to handle an attribute for
        !            96:         * @param handler               handler we requested the attribute for, if any
        !            97:         * @param type                  type of configuration attribute
        !            98:         * @param data                  associated attribute data
        !            99:         * @return                              handler which handled this attribute, NULL if none
        !           100:         */
        !           101:        attribute_handler_t* (*handle)(attribute_manager_t *this,
        !           102:                                                ike_sa_t *ike_sa, attribute_handler_t *handler,
        !           103:                                                configuration_attribute_type_t type, chunk_t data);
        !           104: 
        !           105:        /**
        !           106:         * Release an attribute previously handle()d by a handler.
        !           107:         *
        !           108:         * @param ike_sa                associated IKE_SA to release an attribute for
        !           109:         * @param server                server from which the attribute was received
        !           110:         * @param type                  type of attribute to release
        !           111:         * @param data                  associated attribute data
        !           112:         */
        !           113:        void (*release)(attribute_manager_t *this, attribute_handler_t *handler,
        !           114:                                                ike_sa_t *ike_sa, configuration_attribute_type_t type,
        !           115:                                                chunk_t data);
        !           116: 
        !           117:        /**
        !           118:         * Create an enumerator over attributes to request from server.
        !           119:         *
        !           120:         * @param ike_sa                associated IKE_SA to request attributes for
        !           121:         * @param vip                   list of virtual IPs (host_t*) going to request
        !           122:         * @return                              enumerator (attribute_handler_t, ca_type_t, chunk_t)
        !           123:         */
        !           124:        enumerator_t* (*create_initiator_enumerator)(attribute_manager_t *this,
        !           125:                                                                        ike_sa_t *ike_sa, linked_list_t *vips);
        !           126: 
        !           127:        /**
        !           128:         * Register an attribute handler to the manager.
        !           129:         *
        !           130:         * @param handler               attribute handler to register
        !           131:         */
        !           132:        void (*add_handler)(attribute_manager_t *this,
        !           133:                                                attribute_handler_t *handler);
        !           134: 
        !           135:        /**
        !           136:         * Unregister an attribute handler from the manager.
        !           137:         *
        !           138:         * @param handler               attribute handler to unregister
        !           139:         */
        !           140:        void (*remove_handler)(attribute_manager_t *this,
        !           141:                                                   attribute_handler_t *handler);
        !           142: 
        !           143:        /**
        !           144:         * Destroy a attribute_manager instance.
        !           145:         */
        !           146:        void (*destroy)(attribute_manager_t *this);
        !           147: };
        !           148: 
        !           149: /**
        !           150:  * Create a attribute_manager instance.
        !           151:  */
        !           152: attribute_manager_t *attribute_manager_create();
        !           153: 
        !           154: #endif /** ATTRIBUTE_MANAGER_H_ @}*/

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