Statistics
| Branch: | Tag: | Revision:

root / src / libstrongswan / attributes / attribute_manager.h @ b5a2055fb1b88ea4abb97334d89e311c9ceaa7d4

History | View | Annotate | Download (4.7 KB)

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