2 * @file initiate_ike_sa_job.c
4 * @brief Job of type INITIATE_IKE_SA
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
26 #include "initiate_ike_sa_job.h"
28 #include <utils/allocator.h>
31 * Private data of an initiate_ike_sa_job_t Object
34 typedef struct private_initiate_ike_sa_job_s private_initiate_ike_sa_job_t
;
36 struct private_initiate_ike_sa_job_s
{
38 * public initiate_ike_sa_job_t interface
40 initiate_ike_sa_job_t
public;
43 * Name of the assigned configuration
45 char *configuration_name
;
50 * Implements initiate_ike_sa_job_t's get_type function.
51 * See #initiate_ike_sa_job_t.get_type for description.
53 static job_type_t
get_type(private_initiate_ike_sa_job_t
*this)
55 return INITIATE_IKE_SA
;
59 * Implements initiate_ike_sa_job_t's get_configuration_name function.
60 * See #initiate_ike_sa_job_t.get_configuration_name for description.
62 static char * get_configuration_name(private_initiate_ike_sa_job_t
*this)
64 return this->configuration_name
;
68 * Implements job_t's and initiate_ike_sa_job_t's destroy function.
69 * See #job_t.destroy or #initiate_ike_sa_job_t.destroy for description.
71 static status_t
destroy(job_t
*job
)
73 private_initiate_ike_sa_job_t
*this = (private_initiate_ike_sa_job_t
*) job
;
74 allocator_free(this->configuration_name
);
83 initiate_ike_sa_job_t
*initiate_ike_sa_job_create(char *configuration_name
)
85 private_initiate_ike_sa_job_t
*this = allocator_alloc_thing(private_initiate_ike_sa_job_t
);
86 if ((this == NULL
) || (configuration_name
== NULL
))
91 /* interface functions */
92 this->public.job_interface
.get_type
= (job_type_t (*) (job_t
*)) get_type
;
94 this->public.job_interface
.destroy_all
= (status_t (*) (job_t
*)) destroy
;
95 this->public.job_interface
.destroy
= destroy
;
97 /* public functions */
98 this->public.get_configuration_name
= (char * (*)(initiate_ike_sa_job_t
*)) get_configuration_name
;
99 this->public.destroy
= (status_t (*)(initiate_ike_sa_job_t
*)) destroy
;
101 /* private variables */
102 this->configuration_name
= allocator_alloc(strlen(configuration_name
) + 1);
103 if (this->configuration_name
== NULL
)
105 allocator_free(this);
108 strcpy(this->configuration_name
,configuration_name
);
110 return &(this->public);