IKEv1 XAuth: Added a job to call the initiate_xauth method of ike_sa after the comple...
[strongswan.git] / src / libcharon / processing / jobs / initiate_xauth_job.c
1 /*
2 * Copyright (C) 2007-2008 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "initiate_xauth_job.h"
17
18 #include <sa/ike_sa.h>
19 #include <daemon.h>
20
21
22 typedef struct private_initiate_xauth_job_t private_initiate_xauth_job_t;
23
24 /**
25 * Private data of an initiate_xauth_job_t Object
26 */
27 struct private_initiate_xauth_job_t {
28 /**
29 * public initiate_xauth_job_t interface
30 */
31 initiate_xauth_job_t public;
32
33 /**
34 * ID of the IKE_SA of the mediated connection.
35 */
36 ike_sa_id_t *ike_sa_id;
37 };
38
39 METHOD(job_t, destroy, void,
40 private_initiate_xauth_job_t *this)
41 {
42 DESTROY_IF(this->ike_sa_id);
43 free(this);
44 }
45
46 METHOD(job_t, initiate, void,
47 private_initiate_xauth_job_t *this)
48 {
49 ike_sa_t *ike_sa;
50
51 ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
52 this->ike_sa_id);
53 if (ike_sa)
54 {
55 DBG1(DBG_IKE, "INITIATING XAUTH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
56 ike_sa->initiate_xauth(ike_sa);
57 charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
58 }
59 destroy(this);
60 }
61
62 METHOD(job_t, get_priority, job_priority_t,
63 private_initiate_xauth_job_t *this)
64 {
65 return JOB_PRIO_MEDIUM;
66 }
67
68 /**
69 * Creates an empty job
70 */
71 initiate_xauth_job_t *initiate_xauth_job_create(ike_sa_id_t *ike_sa_id)
72 {
73 private_initiate_xauth_job_t *this;
74 INIT(this,
75 .public = {
76 .job_interface = {
77 .get_priority = _get_priority,
78 .destroy = _destroy,
79 .execute = _initiate,
80 },
81 },
82 .ike_sa_id = ike_sa_id->clone(ike_sa_id),
83 );
84 return &this->public;
85 }