Implement TKM kernel SA database (SAD)
[strongswan.git] / src / charon-tkm / src / tkm / tkm_kernel_sad.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_KERNEL_SAD_H_
18 #define TKM_KERNEL_SAD_H_
19
20 #include <networking/host.h>
21 #include <tkm/types.h>
22
23 typedef struct tkm_kernel_sad_t tkm_kernel_sad_t;
24
25 /**
26 * The TKM kernel SAD (security association database) stores information about
27 * CHILD SAs.
28 */
29 struct tkm_kernel_sad_t {
30
31 /**
32 * Insert new SAD entry with specified parameters.
33 *
34 * @param esa_id ESP SA context identifier
35 * @param src source address of CHILD SA
36 * @param dst destination address of CHILD SA
37 * @param spi SPI of CHILD SA
38 * @param proto protocol of CHILD SA (ESP/AH)
39 * @return TRUE if entry was inserted, FALSE otherwise
40 */
41 bool (*insert)(tkm_kernel_sad_t * const this, const esa_id_type esa_id,
42 const host_t * const src, const host_t * const dst,
43 const u_int32_t spi, const u_int8_t proto);
44
45 /**
46 * Get ESA id for entry with given parameters.
47 *
48 * @param src source address of CHILD SA
49 * @param dst destination address of CHILD SA
50 * @param spi SPI of CHILD SA
51 * @param proto protocol of CHILD SA (ESP/AH)
52 * @return ESA id of entry if found, 0 otherwise
53 */
54 esa_id_type (*get_esa_id)(tkm_kernel_sad_t * const this,
55 const host_t * const src, const host_t * const dst,
56 const u_int32_t spi, const u_int8_t proto);
57
58 /**
59 * Remove entry with given ESA id from SAD.
60 *
61 * @param esa_id ESA identifier of entry to remove
62 * @return TRUE if entry was removed, FALSE otherwise
63 */
64 bool (*remove)(tkm_kernel_sad_t * const this, const esa_id_type esa_id);
65
66 /**
67 * Destroy a tkm_kernel_sad instance.
68 */
69 void (*destroy)(tkm_kernel_sad_t *this);
70
71 };
72
73 /**
74 * Create a TKM kernel SAD instance.
75 */
76 tkm_kernel_sad_t *tkm_kernel_sad_create();
77
78 #endif /** TKM_KERNEL_SAD_H_ */