Migrated ike_dpd to INIT/METHOD macros
[strongswan.git] / src / libcharon / sa / tasks / ike_dpd.c
1 /*
2 * Copyright (C) 2007 Martin Willi
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 "ike_dpd.h"
17
18 #include <daemon.h>
19
20
21 typedef struct private_ike_dpd_t private_ike_dpd_t;
22
23 /**
24 * Private members of a ike_dpd_t task.
25 */
26 struct private_ike_dpd_t {
27
28 /**
29 * Public methods and task_t interface.
30 */
31 ike_dpd_t public;
32 };
33
34 METHOD(task_t, return_need_more, status_t,
35 private_ike_dpd_t *this, message_t *message)
36 {
37 return NEED_MORE;
38 }
39
40 METHOD(task_t, return_success, status_t,
41 private_ike_dpd_t *this, message_t *message)
42 {
43 return SUCCESS;
44 }
45
46 METHOD(task_t, get_type, task_type_t,
47 private_ike_dpd_t *this)
48 {
49 return IKE_DPD;
50 }
51
52
53 METHOD(task_t, migrate, void,
54 private_ike_dpd_t *this, ike_sa_t *ike_sa)
55 {
56
57 }
58
59 METHOD(task_t, destroy, void,
60 private_ike_dpd_t *this)
61 {
62 free(this);
63 }
64
65 /*
66 * Described in header.
67 */
68 ike_dpd_t *ike_dpd_create(bool initiator)
69 {
70 private_ike_dpd_t *this;
71
72 INIT(this,
73 .public = {
74 .task = {
75 .get_type = _get_type,
76 .migrate = _migrate,
77 .destroy = _destroy,
78 },
79 },
80 );
81
82 if (initiator)
83 {
84 this->public.task.build = _return_need_more;
85 this->public.task.process = _return_success;
86 }
87 else
88 {
89 this->public.task.build = _return_success;
90 this->public.task.process = _return_need_more;
91 }
92
93 return &this->public;
94 }