Added a quick mode task stub
[strongswan.git] / src / libcharon / sa / tasks / quick_mode.c
1 /*
2 * Copyright (C) 2011 Martin Willi
3 * Copyright (C) 2011 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 "quick_mode.h"
17
18 #include <string.h>
19
20 #include <daemon.h>
21
22 typedef struct private_quick_mode_t private_quick_mode_t;
23
24 /**
25 * Private members of a quick_mode_t task.
26 */
27 struct private_quick_mode_t {
28
29 /**
30 * Public methods and task_t interface.
31 */
32 quick_mode_t public;
33
34 /**
35 * Assigned IKE_SA.
36 */
37 ike_sa_t *ike_sa;
38
39 /**
40 * Traffic selector of initiator
41 */
42 traffic_selector_t *tsi;
43
44 /**
45 * Traffic selector of responder
46 */
47 traffic_selector_t *tsr;
48
49 /**
50 * Initiators nonce
51 */
52 chunk_t nonce_i;
53
54 /**
55 * Responder nonce
56 */
57 chunk_t nonce_r;
58
59 /**
60 * selected CHILD_SA proposal
61 */
62 proposal_t *proposal;
63
64 /**
65 * Config of CHILD_SA to establish
66 */
67 child_cfg_t *config;
68
69 /**
70 * CHILD_SA we are about to establish
71 */
72 child_sa_t *child_sa;
73
74 /** states of quick mode */
75 enum {
76 QM_INIT,
77 } state;
78 };
79
80 METHOD(task_t, build_i, status_t,
81 private_quick_mode_t *this, message_t *message)
82 {
83 return NEED_MORE;
84 }
85
86 METHOD(task_t, process_r, status_t,
87 private_quick_mode_t *this, message_t *message)
88 {
89 return NEED_MORE;
90 }
91
92 METHOD(task_t, build_r, status_t,
93 private_quick_mode_t *this, message_t *message)
94 {
95 return SUCCESS;
96 }
97
98 METHOD(task_t, process_i, status_t,
99 private_quick_mode_t *this, message_t *message)
100 {
101 return SUCCESS;
102 }
103
104 METHOD(task_t, get_type, task_type_t,
105 private_quick_mode_t *this)
106 {
107 return TASK_QUICK_MODE;
108 }
109
110 METHOD(task_t, migrate, void,
111 private_quick_mode_t *this, ike_sa_t *ike_sa)
112 {
113 this->ike_sa = ike_sa;
114 }
115
116 METHOD(task_t, destroy, void,
117 private_quick_mode_t *this)
118 {
119 chunk_free(&this->nonce_i);
120 chunk_free(&this->nonce_r);
121 DESTROY_IF(this->tsi);
122 DESTROY_IF(this->tsr);
123 DESTROY_IF(this->proposal);
124 DESTROY_IF(this->child_sa);
125 DESTROY_IF(this->config);
126 free(this);
127 }
128
129 /*
130 * Described in header.
131 */
132 quick_mode_t *quick_mode_create(ike_sa_t *ike_sa, child_cfg_t *config,
133 traffic_selector_t *tsi, traffic_selector_t *tsr)
134 {
135 private_quick_mode_t *this;
136
137 INIT(this,
138 .public = {
139 .task = {
140 .get_type = _get_type,
141 .migrate = _migrate,
142 .destroy = _destroy,
143 },
144 },
145 .ike_sa = ike_sa,
146 .tsi = tsi ? tsi->clone(tsi) : NULL,
147 .tsr = tsr ? tsr->clone(tsr) : NULL,
148 .config = config,
149 .state = QM_INIT,
150 );
151
152 if (config)
153 {
154 this->public.task.build = _build_i;
155 this->public.task.process = _process_i;
156 }
157 else
158 {
159 this->public.task.build = _build_r;
160 this->public.task.process = _process_r;
161 }
162
163 return &this->public;
164 }