- added new job type delete_ike_sa_job_t
[strongswan.git] / Source / charon / jobs / delete_ike_sa_job.c
1 /**
2 * @file delete_ike_sa_job.h
3 *
4 * @brief Job of type DELETE_IKE_SA
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, 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_ike_sa_job.h"
24
25 #include "../utils/allocator.h"
26
27 /**
28 * Private data of an delete_ike_sa_job_t Object
29 *
30 */
31 typedef struct private_delete_ike_sa_job_s private_delete_ike_sa_job_t;
32
33 struct private_delete_ike_sa_job_s {
34 /**
35 * public delete_ike_sa_job_t interface
36 */
37 delete_ike_sa_job_t public;
38
39 /**
40 * ID of the ike_sa to delete
41 */
42 ike_sa_id_t *ike_sa_id;
43 };
44
45
46 /**
47 * Implements delete_ike_sa_job_t's get_type function.
48 * See #delete_ike_sa_job_t.get_type for description.
49 */
50 static job_type_t get_type(private_delete_ike_sa_job_t *this)
51 {
52 return DELETE_IKE_SA;
53 }
54
55 /**
56 * Implements delete_ike_sa_job_t's get_ike_sa_id function.
57 * See #delete_ike_sa_job_t.get_ike_sa_id for description.
58 */
59 static ike_sa_id_t * get_ike_sa_id(private_delete_ike_sa_job_t *this)
60 {
61 return this->ike_sa_id;
62 }
63
64 /**
65 * Implements job_t's and delete_ike_sa_job_t's destroy function.
66 * See #job_t.destroy or #delete_ike_sa_job_t.destroy for description.
67 */
68 static status_t destroy(job_t *job)
69 {
70 private_delete_ike_sa_job_t *this = (private_delete_ike_sa_job_t *) job;
71 this->ike_sa_id->destroy(this->ike_sa_id);
72 allocator_free(this);
73 return SUCCESS;
74 }
75
76 /*
77 * Described in header
78 */
79 delete_ike_sa_job_t *delete_ike_sa_job_create(ike_sa_id_t *ike_sa_id)
80 {
81 private_delete_ike_sa_job_t *this = allocator_alloc_thing(private_delete_ike_sa_job_t);
82 if (this == NULL)
83 {
84 return NULL;
85 }
86
87 /* interface functions */
88 this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
89 /* same as destroy */
90 this->public.job_interface.destroy_all = (status_t (*) (job_t *)) destroy;
91 this->public.job_interface.destroy = destroy;
92
93 /* public functions */
94 this->public.get_ike_sa_id = (ike_sa_id_t * (*)(delete_ike_sa_job_t *)) get_ike_sa_id;
95 this->public.destroy = (status_t (*)(delete_ike_sa_job_t *)) destroy;
96
97 /* private variables */
98 if (ike_sa_id->clone(ike_sa_id,&(this->ike_sa_id)) != SUCCESS)
99 {
100 allocator_free(this);
101 return NULL;
102 }
103
104 return &(this->public);
105 }