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
;
69 * Implements job_t's and initiate_ike_sa_job_t's destroy function.
70 * See #job_t.destroy or #initiate_ike_sa_job_t.destroy for description.
72 static status_t
destroy(job_t
*job
)
74 private_initiate_ike_sa_job_t
*this = (private_initiate_ike_sa_job_t
*) job
;
75 allocator_free(this->configuration_name
);
84 initiate_ike_sa_job_t
*initiate_ike_sa_job_create(char *configuration_name
)
86 private_initiate_ike_sa_job_t
*this = allocator_alloc_thing(private_initiate_ike_sa_job_t
);
87 if ((this == NULL
) || (configuration_name
== NULL
))
92 /* interface functions */
93 this->public.job_interface
.get_type
= (job_type_t (*) (job_t
*)) get_type
;
94 this->public.job_interface
.destroy
= destroy
;
96 /* public functions */
97 this->public.get_configuration_name
= (char * (*)(initiate_ike_sa_job_t
*)) get_configuration_name
;
98 this->public.destroy
= (status_t (*)(initiate_ike_sa_job_t
*)) destroy
;
100 /* private variables */
101 this->configuration_name
= allocator_alloc(sizeof(configuration_name
) + 1);
102 if (this->configuration_name
== NULL
)
104 allocator_free(this);
107 strcpy(this->configuration_name
,configuration_name
);
109 return &(this->public);