Annotation of embedaddon/strongswan/src/libcharon/processing/jobs/initiate_tasks_job.c, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2015 Martin Willi
3: * Copyright (C) 2015 revosec AG
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 <stdlib.h>
17:
18: #include "initiate_tasks_job.h"
19:
20: #include <sa/ike_sa.h>
21: #include <daemon.h>
22:
23:
24: typedef struct private_initiate_tasks_job_t private_initiate_tasks_job_t;
25:
26: /**
27: * Private data of an initiate_tasks_job_t Object
28: */
29: struct private_initiate_tasks_job_t {
30:
31: /**
32: * Public initiate_tasks_job_t interface
33: */
34: initiate_tasks_job_t public;
35:
36: /**
37: * ID of the IKE_SA to trigger task initiation
38: */
39: ike_sa_id_t *ike_sa_id;
40: };
41:
42: METHOD(job_t, destroy, void,
43: private_initiate_tasks_job_t *this)
44: {
45: this->ike_sa_id->destroy(this->ike_sa_id);
46: free(this);
47: }
48:
49: METHOD(job_t, execute, job_requeue_t,
50: private_initiate_tasks_job_t *this)
51: {
52: ike_sa_t *ike_sa;
53:
54: ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
55: this->ike_sa_id);
56: if (ike_sa)
57: {
58: if (ike_sa->initiate(ike_sa, NULL, 0, NULL, NULL) == DESTROY_ME)
59: {
60: charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager,
61: ike_sa);
62: }
63: else
64: {
65: charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
66: }
67: }
68: return JOB_REQUEUE_NONE;
69: }
70:
71: METHOD(job_t, get_priority, job_priority_t,
72: private_initiate_tasks_job_t *this)
73: {
74: return JOB_PRIO_MEDIUM;
75: }
76:
77: /*
78: * Described in header
79: */
80: initiate_tasks_job_t *initiate_tasks_job_create(ike_sa_id_t *ike_sa_id)
81: {
82: private_initiate_tasks_job_t *this;
83:
84: INIT(this,
85: .public = {
86: .job_interface = {
87: .execute = _execute,
88: .get_priority = _get_priority,
89: .destroy = _destroy,
90: },
91: },
92: .ike_sa_id = ike_sa_id->clone(ike_sa_id),
93: );
94:
95: return &this->public;
96: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>