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