Initialize TKM client library in tkm.c
[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
32 /** helper to determine the number of elements in this enum */
33 TKM_CTX_MAX,
34 };
35
36 /**
37 * enum name for context_kind_t.
38 */
39 extern enum_name_t *tkm_context_kind_names;
40
41 /**
42 * The tkm id manager hands out context ids for all context kinds (e.g. nonce).
43 */
44 struct tkm_id_manager_t {
45
46 /**
47 * Acquire new context id for a specific context kind.
48 *
49 * @param kind kind of context id to acquire
50 * @return context id of given kind,
51 * 0 if no id of given kind could be acquired
52 */
53 int (*acquire_id)(tkm_id_manager_t * const this,
54 const tkm_context_kind_t kind);
55
56 /**
57 * Release a previously acquired context id.
58 *
59 * @param kind kind of context id to release
60 * @param id id to release
61 * @return TRUE if id was released, FALSE otherwise
62 */
63 bool (*release_id)(tkm_id_manager_t * const this,
64 const tkm_context_kind_t kind,
65 const int id);
66
67 /**
68 * Destroy a tkm_id_manager instance.
69 */
70 void (*destroy)(tkm_id_manager_t *this);
71
72 };
73
74 /**
75 * Create a tkm id manager instance.
76 */
77 tkm_id_manager_t *tkm_id_manager_create();
78
79 #endif /** TKM_ID_MANAGER_H_ */