nonceg: Insert id mapping when allocating nonce
[strongswan.git] / src / charon-tkm / src / tkm / tkm_chunk_map.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_CHUNK_MAP_H_
18 #define TKM_CHUNK_MAP_H_
19
20 #include <stdint.h>
21 #include <utils/chunk.h>
22
23 typedef struct tkm_chunk_map_t tkm_chunk_map_t;
24
25 /**
26 * The tkm chunk map handles mappings of chunks to ids.
27 */
28 struct tkm_chunk_map_t {
29
30 /**
31 * Store new mapping for given chunk and id.
32 *
33 * @param data data associated with id
34 * @param id id associated with data
35 */
36 void (*insert)(tkm_chunk_map_t * const this, const chunk_t * const data,
37 const uint64_t id);
38
39 /**
40 * Get id for given chunk.
41 *
42 * @param data data specifying the mapping
43 * @return id of given chunk, 0 if not found
44 */
45 uint64_t (*get_id)(tkm_chunk_map_t * const this, chunk_t *data);
46
47 /**
48 * Remove mapping for given chunk.
49 *
50 * @param data data specifiying the mapping to remove
51 * @return TRUE if mapping was removed, FALSE otherwise
52 */
53 bool (*remove)(tkm_chunk_map_t * const this, chunk_t *data);
54
55 /**
56 * Destroy a tkm chunk map instance.
57 */
58 void (*destroy)(tkm_chunk_map_t *this);
59
60 };
61
62 /**
63 * Create a tkm chunk map instance.
64 */
65 tkm_chunk_map_t *tkm_chunk_map_create();
66
67 #endif /** TKM_CHUNK_MAP_H_ */