0af8ea7ecff96a34cad9716eb1f7f6fe6519cd44
2 * Copyright (C) 2007 Tobias Brunner
3 * Copyright (C) 2006 Martin Willi
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 typedef enum task_type_t task_type_t
;
26 typedef struct task_t task_t
;
29 #include <sa/ike_sa.h>
30 #include <encoding/message.h>
33 * Different kinds of tasks.
36 /** establish an unauthenticated IKE_SA */
38 /** detect NAT situation */
40 /** handle MOBIKE stuff */
42 /** authenticate the initiated IKE_SA */
44 /** AUTH_LIFETIME negotiation, RFC4478 */
45 TASK_IKE_AUTH_LIFETIME
,
46 /** certificate processing before authentication (certreqs, cert parsing) */
48 /** certificate processing after authentication (certs payload generation) */
50 /** Configuration payloads, virtual IP and such */
52 /** rekey an IKE_SA */
54 /** reestablish a complete IKE_SA */
56 /** delete an IKE_SA */
60 /** Vendor ID processing */
63 /** handle ME stuff */
66 /** establish a CHILD_SA within an IKE_SA */
68 /** delete an established CHILD_SA */
70 /** rekey an CHILD_SA */
72 /** IKEv1 main mode */
74 /** IKEv1 informational exchange */
76 /** IKEv1 delete using an informational */
78 /** IKEv1 XAUTH authentication */
80 /** IKEv1 Mode Config */
82 /** IKEv1 quick mode */
84 /** IKEv1 delete of a quick mode SA */
86 /** IKEv1 vendor ID payload handling */
88 /** IKEv1 NAT detection */
90 /** IKEv1 pre-authentication certificate handling */
92 /** IKEv1 post-authentication certificate handling */
93 TASK_ISAKMP_CERT_POST
,
97 * enum names for task_type_t.
99 extern enum_name_t
*task_type_names
;
102 * Interface for a task, an operation handled within exchanges.
104 * A task is an elemantary operation. It may be handled by a single or by
105 * multiple exchanges. An exchange may even complete multiple tasks.
106 * A task has a build() and an process() operation. The build() operation
107 * creates payloads and adds it to the message. The process() operation
108 * inspects a message and handles its payloads. An initiator of an exchange
109 * first calls build() to build the request, and processes the response message
110 * with the process() method.
111 * A responder does the opposite; it calls process() first to handle an incoming
112 * request and secondly calls build() to build an appropriate response.
113 * Both methods return either SUCCESS, NEED_MORE or FAILED. A SUCCESS indicates
114 * that the task completed, even when the task completed unsuccessfully. The
115 * manager then removes the task from the list. A NEED_MORE is returned when
116 * the task needs further build()/process() calls to complete, the manager
117 * leaves the taks in the queue. A returned FAILED indicates a critical failure.
118 * The manager closes the IKE_SA whenever a task returns FAILED.
123 * Build a request or response message for this task.
125 * @param message message to add payloads to
127 * - FAILED if a critical error occurred
128 * - DESTROY_ME if IKE_SA has been properly deleted
129 * - NEED_MORE if another call to build/process needed
130 * - ALREADY_DONE to cancel all active or passive tasks
131 * - SUCCESS if task completed
133 status_t (*build
) (task_t
*this, message_t
*message
);
136 * Process a request or response message for this task.
138 * @param message message to read payloads from
140 * - FAILED if a critical error occurred
141 * - DESTROY_ME if IKE_SA has been properly deleted
142 * - NEED_MORE if another call to build/process needed
143 * - ALREADY_DONE to cancel all active or passive tasks
144 * - SUCCESS if task completed
146 status_t (*process
) (task_t
*this, message_t
*message
);
149 * Get the type of the task implementation.
151 task_type_t (*get_type
) (task_t
*this);
154 * Migrate a task to a new IKE_SA.
156 * After migrating a task, it goes back to a state where it can be
157 * used again to initate an exchange. This is useful when a task
158 * has to get migrated to a new IKE_SA.
159 * A special usage is when a INVALID_KE_PAYLOAD is received. A call
160 * to reset resets the task, but uses another DH group for the next
162 * The ike_sa is the new IKE_SA this task belongs to and operates on.
164 * @param ike_sa new IKE_SA this task works for
166 void (*migrate
) (task_t
*this, ike_sa_t
*ike_sa
);
169 * Destroys a task_t object.
171 void (*destroy
) (task_t
*this);
174 #endif /** TASK_H_ @}*/