]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/charon/queues/jobs/delete_child_sa_job.c
adapt evaltest to changed debug output
[thirdparty/strongswan.git] / src / charon / queues / jobs / delete_child_sa_job.c
1 /**
2 * @file delete_child_sa_job.c
3 *
4 * @brief Implementation of delete_child_sa_job_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include "delete_child_sa_job.h"
24
25 #include <daemon.h>
26
27
28 typedef struct private_delete_child_sa_job_t private_delete_child_sa_job_t;
29
30 /**
31 * Private data of an delete_child_sa_job_t object.
32 */
33 struct private_delete_child_sa_job_t {
34 /**
35
36 * Public delete_child_sa_job_t interface.
37 */
38 delete_child_sa_job_t public;
39
40 /**
41 * reqid of the CHILD_SA
42 */
43 u_int32_t reqid;
44
45 /**
46 * protocol of the CHILD_SA (ESP/AH)
47 */
48 protocol_id_t protocol;
49
50 /**
51 * inbound SPI of the CHILD_SA
52 */
53 u_int32_t spi;
54 };
55
56 /**
57 * Implementation of job_t.get_type.
58 */
59 static job_type_t get_type(private_delete_child_sa_job_t *this)
60 {
61 return DELETE_CHILD_SA;
62 }
63
64 /**
65 * Implementation of job_t.execute.
66 */
67 static status_t execute(private_delete_child_sa_job_t *this)
68 {
69 ike_sa_t *ike_sa;
70
71 ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
72 this->reqid, TRUE);
73 if (ike_sa == NULL)
74 {
75 DBG1(DBG_JOB, "CHILD_SA with reqid %d not found for delete",
76 this->reqid);
77 return DESTROY_ME;
78 }
79 ike_sa->delete_child_sa(ike_sa, this->protocol, this->spi);
80
81 charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
82 return DESTROY_ME;
83 }
84
85 /**
86 * Implementation of job_t.destroy.
87 */
88 static void destroy(private_delete_child_sa_job_t *this)
89 {
90 free(this);
91 }
92
93 /*
94 * Described in header
95 */
96 delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
97 protocol_id_t protocol,
98 u_int32_t spi)
99 {
100 private_delete_child_sa_job_t *this = malloc_thing(private_delete_child_sa_job_t);
101
102 /* interface functions */
103 this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
104 this->public.job_interface.execute = (status_t (*) (job_t *)) execute;
105 this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
106
107 /* private variables */
108 this->reqid = reqid;
109 this->protocol = protocol;
110 this->spi = spi;
111
112 return &(this->public);
113 }