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