74c0d3618a003a8915a73f0559655121cc43f003
[strongswan.git] / src / charon-tkm / src / ees / ees_callbacks.c
1 /*
2 * Copyright (C) 2012-2014 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 #include <hydra.h>
18 #include <utils/debug.h>
19 #include <tkm/constants.h>
20 #include <tkm/types.h>
21
22 #include "tkm.h"
23 #include "ees_callbacks.h"
24
25 void charon_esa_acquire(result_type *res, const sp_id_type sp_id)
26 {
27 DBG1(DBG_KNL, "ees: acquire received for reqid %u", sp_id);
28 hydra->kernel_interface->acquire(hydra->kernel_interface, sp_id, NULL,
29 NULL);
30 *res = TKM_OK;
31 }
32
33 void charon_esa_expire(result_type *res, const sp_id_type sp_id,
34 const esp_spi_type spi_rem, const protocol_type protocol,
35 const expiry_flag_type hard)
36 {
37 host_t *dst;
38
39 dst = tkm->sad->get_dst_host(tkm->sad, sp_id, spi_rem, protocol);
40 *res = TKM_OK;
41 if (dst == NULL)
42 {
43 DBG3(DBG_KNL, "ees: destination host not found for reqid %u, spi %x, "
44 "proto %u", sp_id, ntohl(spi_rem), protocol);
45 return;
46 }
47
48 DBG1(DBG_KNL, "ees: expire received for reqid %u, spi %x, dst %H", sp_id,
49 ntohl(spi_rem), dst);
50 hydra->kernel_interface->expire(hydra->kernel_interface, protocol,
51 spi_rem, dst, hard != 0);
52 }