Use ikev2 keymat proxy
[strongswan.git] / src / charon-tkm / src / tkm / tkm_id_manager.h
1 /*
2 * Copyright (C) 2012 Reto Buerki
3 * Copyright (C) 2012 Adrian-Ken Rueegsegger
4 * 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 #ifndef TKM_ID_MANAGER_H_
18 #define TKM_ID_MANAGER_H_
19
20 #include <library.h>
21
22 typedef struct tkm_id_manager_t tkm_id_manager_t;
23 typedef enum tkm_context_kind_t tkm_context_kind_t;
24
25 /**
26 * Trusted key manager context kinds.
27 */
28 enum tkm_context_kind_t {
29 /** Nonce context */
30 TKM_CTX_NONCE,
31 /** Diffie-Hellman context */
32 TKM_CTX_DH,
33
34 /** helper to determine the number of elements in this enum */
35 TKM_CTX_MAX,
36 };
37
38 /**
39 * enum name for context_kind_t.
40 */
41 extern enum_name_t *tkm_context_kind_names;
42
43 /**
44 * TKM context limits.
45 */
46 typedef uint64_t tkm_limits_t[TKM_CTX_MAX];
47
48 /**
49 * The tkm id manager hands out context ids for all context kinds (e.g. nonce).
50 */
51 struct tkm_id_manager_t {
52
53 /**
54 * Acquire new context id for a specific context kind.
55 *
56 * @param kind kind of context id to acquire
57 * @return context id of given kind,
58 * 0 if no id of given kind could be acquired
59 */
60 int (*acquire_id)(tkm_id_manager_t * const this,
61 const tkm_context_kind_t kind);
62
63 /**
64 * Release a previously acquired context id.
65 *
66 * @param kind kind of context id to release
67 * @param id id to release
68 * @return TRUE if id was released, FALSE otherwise
69 */
70 bool (*release_id)(tkm_id_manager_t * const this,
71 const tkm_context_kind_t kind,
72 const int id);
73
74 /**
75 * Destroy a tkm_id_manager instance.
76 */
77 void (*destroy)(tkm_id_manager_t *this);
78
79 };
80
81 /**
82 * Create a tkm id manager instance using the given context limits.
83 */
84 tkm_id_manager_t *tkm_id_manager_create(const tkm_limits_t limits);
85
86 #endif /** TKM_ID_MANAGER_H_ */