libhydra: Move kernel interface to libcharon
[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 <daemon.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 charon->kernel->acquire(charon->kernel, sp_id, NULL, NULL);
29 *res = TKM_OK;
30 }
31
32 void charon_esa_expire(result_type *res, const sp_id_type sp_id,
33 const esp_spi_type spi_rem, const protocol_type protocol,
34 const expiry_flag_type hard)
35 {
36 host_t *dst;
37
38 dst = tkm->sad->get_dst_host(tkm->sad, sp_id, spi_rem, protocol);
39 *res = TKM_OK;
40 if (dst == NULL)
41 {
42 DBG3(DBG_KNL, "ees: destination host not found for reqid %u, spi %x, "
43 "proto %u", sp_id, ntohl(spi_rem), protocol);
44 return;
45 }
46
47 DBG1(DBG_KNL, "ees: expire received for reqid %u, spi %x, dst %H", sp_id,
48 ntohl(spi_rem), dst);
49 charon->kernel->expire(charon->kernel, protocol, spi_rem, dst, hard != 0);
50 }