5392869385e9d60440f3d0c60f6e2ba1fc535c97
[strongswan.git] / src / libcharon / sa / ikev1 / tasks / main_mode.c
1 /*
2 * Copyright (C) 2011-2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * Copyright (C) 2011 Martin Willi
6 * Copyright (C) 2011 revosec AG
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 */
18
19 #include "main_mode.h"
20
21 #include <string.h>
22
23 #include <daemon.h>
24 #include <sa/ikev1/phase1.h>
25 #include <encoding/payloads/sa_payload.h>
26 #include <encoding/payloads/id_payload.h>
27 #include <encoding/payloads/hash_payload.h>
28 #include <sa/ikev1/tasks/xauth.h>
29 #include <sa/ikev1/tasks/mode_config.h>
30 #include <sa/ikev1/tasks/informational.h>
31 #include <sa/ikev1/tasks/isakmp_delete.h>
32 #include <processing/jobs/adopt_children_job.h>
33
34 typedef struct private_main_mode_t private_main_mode_t;
35
36 /**
37 * Private members of a main_mode_t task.
38 */
39 struct private_main_mode_t {
40
41 /**
42 * Public methods and task_t interface.
43 */
44 main_mode_t public;
45
46 /**
47 * Assigned IKE_SA.
48 */
49 ike_sa_t *ike_sa;
50
51 /**
52 * Are we the initiator?
53 */
54 bool initiator;
55
56 /**
57 * Common phase 1 helper class
58 */
59 phase1_t *ph1;
60
61 /**
62 * IKE config to establish
63 */
64 ike_cfg_t *ike_cfg;
65
66 /**
67 * Peer config to use
68 */
69 peer_cfg_t *peer_cfg;
70
71 /**
72 * selected IKE proposal
73 */
74 proposal_t *proposal;
75
76 /**
77 * Negotiated SA lifetime
78 */
79 u_int32_t lifetime;
80
81 /**
82 * Negotiated authentication method
83 */
84 auth_method_t method;
85
86 /** states of main mode */
87 enum {
88 MM_INIT,
89 MM_SA,
90 MM_KE,
91 MM_AUTH,
92 } state;
93 };
94
95 /**
96 * Set IKE_SA to established state
97 */
98 static bool establish(private_main_mode_t *this)
99 {
100 if (!charon->bus->authorize(charon->bus, TRUE))
101 {
102 DBG1(DBG_IKE, "final authorization hook forbids IKE_SA, cancelling");
103 return FALSE;
104 }
105
106 DBG0(DBG_IKE, "IKE_SA %s[%d] established between %H[%Y]...%H[%Y]",
107 this->ike_sa->get_name(this->ike_sa),
108 this->ike_sa->get_unique_id(this->ike_sa),
109 this->ike_sa->get_my_host(this->ike_sa),
110 this->ike_sa->get_my_id(this->ike_sa),
111 this->ike_sa->get_other_host(this->ike_sa),
112 this->ike_sa->get_other_id(this->ike_sa));
113
114 this->ike_sa->set_state(this->ike_sa, IKE_ESTABLISHED);
115 charon->bus->ike_updown(charon->bus, this->ike_sa, TRUE);
116
117 return TRUE;
118 }
119
120 /**
121 * Check for notify errors, return TRUE if error found
122 */
123 static bool has_notify_errors(private_main_mode_t *this, message_t *message)
124 {
125 enumerator_t *enumerator;
126 payload_t *payload;
127 bool err = FALSE;
128
129 enumerator = message->create_payload_enumerator(message);
130 while (enumerator->enumerate(enumerator, &payload))
131 {
132 if (payload->get_type(payload) == NOTIFY_V1)
133 {
134 notify_payload_t *notify;
135 notify_type_t type;
136
137 notify = (notify_payload_t*)payload;
138 type = notify->get_notify_type(notify);
139 if (type < 16384)
140 {
141 DBG1(DBG_IKE, "received %N error notify",
142 notify_type_names, type);
143 err = TRUE;
144 }
145 else if (type == INITIAL_CONTACT_IKEV1)
146 {
147 if (!this->initiator && this->state == MM_AUTH)
148 {
149 /* If authenticated and received INITIAL_CONTACT,
150 * delete any existing IKE_SAs with that peer.
151 * The delete takes place when the SA is checked in due
152 * to other id not known until the 3rd message.*/
153 this->ike_sa->set_condition(this->ike_sa,
154 COND_INIT_CONTACT_SEEN, TRUE);
155 }
156 }
157 else
158 {
159 DBG1(DBG_IKE, "received %N notify", notify_type_names, type);
160 }
161 }
162 }
163 enumerator->destroy(enumerator);
164
165 return err;
166 }
167
168 /**
169 * Queue a task sending a notify in an INFORMATIONAL exchange
170 */
171 static status_t send_notify(private_main_mode_t *this, notify_type_t type)
172 {
173 notify_payload_t *notify;
174 ike_sa_id_t *ike_sa_id;
175 u_int64_t spi_i, spi_r;
176 chunk_t spi;
177
178 notify = notify_payload_create_from_protocol_and_type(NOTIFY_V1,
179 PROTO_IKE, type);
180 ike_sa_id = this->ike_sa->get_id(this->ike_sa);
181 spi_i = ike_sa_id->get_initiator_spi(ike_sa_id);
182 spi_r = ike_sa_id->get_responder_spi(ike_sa_id);
183 spi = chunk_cata("cc", chunk_from_thing(spi_i), chunk_from_thing(spi_r));
184 notify->set_spi_data(notify, spi);
185
186 this->ike_sa->queue_task(this->ike_sa,
187 (task_t*)informational_create(this->ike_sa, notify));
188 /* cancel all active/passive tasks in favour of informational */
189 this->ike_sa->flush_queue(this->ike_sa,
190 this->initiator ? TASK_QUEUE_ACTIVE : TASK_QUEUE_PASSIVE);
191 return ALREADY_DONE;
192 }
193
194 /**
195 * Queue a delete task if authentication failed as initiator
196 */
197 static status_t send_delete(private_main_mode_t *this)
198 {
199 this->ike_sa->queue_task(this->ike_sa,
200 (task_t*)isakmp_delete_create(this->ike_sa, TRUE));
201 /* cancel all active tasks in favour of informational */
202 this->ike_sa->flush_queue(this->ike_sa,
203 this->initiator ? TASK_QUEUE_ACTIVE : TASK_QUEUE_PASSIVE);
204 return ALREADY_DONE;
205 }
206
207 METHOD(task_t, build_i, status_t,
208 private_main_mode_t *this, message_t *message)
209 {
210 switch (this->state)
211 {
212 case MM_INIT:
213 {
214 sa_payload_t *sa_payload;
215 linked_list_t *proposals;
216 packet_t *packet;
217
218 DBG0(DBG_IKE, "initiating Main Mode IKE_SA %s[%d] to %H",
219 this->ike_sa->get_name(this->ike_sa),
220 this->ike_sa->get_unique_id(this->ike_sa),
221 this->ike_sa->get_other_host(this->ike_sa));
222 this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);
223
224 this->ike_cfg = this->ike_sa->get_ike_cfg(this->ike_sa);
225 this->peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
226 this->peer_cfg->get_ref(this->peer_cfg);
227
228 this->method = this->ph1->get_auth_method(this->ph1, this->peer_cfg);
229 if (this->method == AUTH_NONE)
230 {
231 DBG1(DBG_CFG, "configuration uses unsupported authentication");
232 return FAILED;
233 }
234 this->lifetime = this->peer_cfg->get_reauth_time(this->peer_cfg,
235 FALSE);
236 if (!this->lifetime)
237 { /* fall back to rekey time of no rekey time configured */
238 this->lifetime = this->peer_cfg->get_rekey_time(this->peer_cfg,
239 FALSE);
240 }
241 this->lifetime += this->peer_cfg->get_over_time(this->peer_cfg);
242 proposals = this->ike_cfg->get_proposals(this->ike_cfg);
243 sa_payload = sa_payload_create_from_proposals_v1(proposals,
244 this->lifetime, 0, this->method, MODE_NONE, FALSE, 0);
245 proposals->destroy_offset(proposals, offsetof(proposal_t, destroy));
246
247 message->add_payload(message, &sa_payload->payload_interface);
248
249 /* pregenerate message to store SA payload */
250 if (this->ike_sa->generate_message(this->ike_sa, message,
251 &packet) != SUCCESS)
252 {
253 DBG1(DBG_IKE, "pregenerating SA payload failed");
254 return FAILED;
255 }
256 packet->destroy(packet);
257 if (!this->ph1->save_sa_payload(this->ph1, message))
258 {
259 return FAILED;
260 }
261
262 this->state = MM_SA;
263 return NEED_MORE;
264 }
265 case MM_SA:
266 {
267 u_int16_t group;
268
269 if (!this->ph1->create_hasher(this->ph1))
270 {
271 return send_notify(this, NO_PROPOSAL_CHOSEN);
272 }
273 if (!this->proposal->get_algorithm(this->proposal,
274 DIFFIE_HELLMAN_GROUP, &group, NULL))
275 {
276 DBG1(DBG_IKE, "DH group selection failed");
277 return send_notify(this, NO_PROPOSAL_CHOSEN);
278 }
279 if (!this->ph1->create_dh(this->ph1, group))
280 {
281 DBG1(DBG_IKE, "negotiated DH group not supported");
282 return send_notify(this, INVALID_KEY_INFORMATION);
283 }
284 if (!this->ph1->add_nonce_ke(this->ph1, message))
285 {
286 return send_notify(this, INVALID_KEY_INFORMATION);
287 }
288 this->state = MM_KE;
289 return NEED_MORE;
290 }
291 case MM_KE:
292 {
293 id_payload_t *id_payload;
294 identification_t *id;
295
296 id = this->ph1->get_id(this->ph1, this->peer_cfg, TRUE);
297 if (!id)
298 {
299 DBG1(DBG_CFG, "own identity not known");
300 return send_notify(this, INVALID_ID_INFORMATION);
301 }
302 this->ike_sa->set_my_id(this->ike_sa, id->clone(id));
303 id_payload = id_payload_create_from_identification(ID_V1, id);
304 message->add_payload(message, &id_payload->payload_interface);
305
306 if (!this->ph1->build_auth(this->ph1, this->method, message,
307 id_payload->get_encoded(id_payload)))
308 {
309 return send_notify(this, AUTHENTICATION_FAILED);
310 }
311
312 this->state = MM_AUTH;
313 return NEED_MORE;
314 }
315 default:
316 return FAILED;
317 }
318 }
319
320 METHOD(task_t, process_r, status_t,
321 private_main_mode_t *this, message_t *message)
322 {
323 switch (this->state)
324 {
325 case MM_INIT:
326 {
327 linked_list_t *list;
328 sa_payload_t *sa_payload;
329 bool private;
330
331 this->ike_cfg = this->ike_sa->get_ike_cfg(this->ike_sa);
332 DBG0(DBG_IKE, "%H is initiating a Main Mode IKE_SA",
333 message->get_source(message));
334 this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);
335
336 this->ike_sa->update_hosts(this->ike_sa,
337 message->get_destination(message),
338 message->get_source(message), TRUE);
339
340 sa_payload = (sa_payload_t*)message->get_payload(message,
341 SECURITY_ASSOCIATION_V1);
342 if (!sa_payload)
343 {
344 DBG1(DBG_IKE, "SA payload missing");
345 return send_notify(this, INVALID_PAYLOAD_TYPE);
346 }
347 if (!this->ph1->save_sa_payload(this->ph1, message))
348 {
349 return send_notify(this, INVALID_PAYLOAD_TYPE);
350 }
351
352 list = sa_payload->get_proposals(sa_payload);
353 private = this->ike_sa->supports_extension(this->ike_sa,
354 EXT_STRONGSWAN);
355 this->proposal = this->ike_cfg->select_proposal(this->ike_cfg,
356 list, private);
357 list->destroy_offset(list, offsetof(proposal_t, destroy));
358 if (!this->proposal)
359 {
360 DBG1(DBG_IKE, "no proposal found");
361 return send_notify(this, NO_PROPOSAL_CHOSEN);
362 }
363 this->ike_sa->set_proposal(this->ike_sa, this->proposal);
364
365 this->method = sa_payload->get_auth_method(sa_payload);
366 this->lifetime = sa_payload->get_lifetime(sa_payload);
367
368 this->state = MM_SA;
369 return NEED_MORE;
370 }
371 case MM_SA:
372 {
373 u_int16_t group;
374
375 if (!this->ph1->create_hasher(this->ph1))
376 {
377 return send_notify(this, INVALID_KEY_INFORMATION);
378 }
379 if (!this->proposal->get_algorithm(this->proposal,
380 DIFFIE_HELLMAN_GROUP, &group, NULL))
381 {
382 DBG1(DBG_IKE, "DH group selection failed");
383 return send_notify(this, INVALID_KEY_INFORMATION);
384 }
385 if (!this->ph1->create_dh(this->ph1, group))
386 {
387 DBG1(DBG_IKE, "negotiated DH group not supported");
388 return send_notify(this, INVALID_KEY_INFORMATION);
389 }
390 if (!this->ph1->get_nonce_ke(this->ph1, message))
391 {
392 return send_notify(this, INVALID_PAYLOAD_TYPE);
393 }
394 this->state = MM_KE;
395 return NEED_MORE;
396 }
397 case MM_KE:
398 {
399 id_payload_t *id_payload;
400 identification_t *id;
401
402 id_payload = (id_payload_t*)message->get_payload(message, ID_V1);
403 if (!id_payload)
404 {
405 DBG1(DBG_IKE, "IDii payload missing");
406 return send_notify(this, INVALID_PAYLOAD_TYPE);
407 }
408 id = id_payload->get_identification(id_payload);
409 this->ike_sa->set_other_id(this->ike_sa, id);
410
411 while (TRUE)
412 {
413 DESTROY_IF(this->peer_cfg);
414 this->peer_cfg = this->ph1->select_config(this->ph1,
415 this->method, FALSE, id);
416 if (!this->peer_cfg)
417 {
418 return send_notify(this, AUTHENTICATION_FAILED);
419 }
420 this->ike_sa->set_peer_cfg(this->ike_sa, this->peer_cfg);
421
422 if (this->ph1->verify_auth(this->ph1, this->method, message,
423 id_payload->get_encoded(id_payload)))
424 {
425 break;
426 }
427 }
428
429 if (!charon->bus->authorize(charon->bus, FALSE))
430 {
431 DBG1(DBG_IKE, "Main Mode authorization hook forbids IKE_SA, "
432 "cancelling");
433 return send_notify(this, AUTHENTICATION_FAILED);
434 }
435
436 this->state = MM_AUTH;
437 if (has_notify_errors(this, message))
438 {
439 return FAILED;
440 }
441 return NEED_MORE;
442 }
443 default:
444 return FAILED;
445 }
446 }
447
448 METHOD(task_t, build_r, status_t,
449 private_main_mode_t *this, message_t *message)
450 {
451 switch (this->state)
452 {
453 case MM_SA:
454 {
455 sa_payload_t *sa_payload;
456
457 sa_payload = sa_payload_create_from_proposal_v1(this->proposal,
458 this->lifetime, 0, this->method, MODE_NONE, FALSE, 0);
459 message->add_payload(message, &sa_payload->payload_interface);
460
461 return NEED_MORE;
462 }
463 case MM_KE:
464 {
465 if (!this->ph1->add_nonce_ke(this->ph1, message))
466 {
467 return send_notify(this, INVALID_KEY_INFORMATION);
468 }
469 if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method))
470 {
471 return send_notify(this, INVALID_KEY_INFORMATION);
472 }
473 return NEED_MORE;
474 }
475 case MM_AUTH:
476 {
477 id_payload_t *id_payload;
478 identification_t *id;
479
480 id = this->ph1->get_id(this->ph1, this->peer_cfg, TRUE);
481 if (!id)
482 {
483 DBG1(DBG_CFG, "own identity not known");
484 return send_notify(this, INVALID_ID_INFORMATION);
485 }
486 this->ike_sa->set_my_id(this->ike_sa, id->clone(id));
487
488 id_payload = id_payload_create_from_identification(ID_V1, id);
489 message->add_payload(message, &id_payload->payload_interface);
490
491 if (!this->ph1->build_auth(this->ph1, this->method, message,
492 id_payload->get_encoded(id_payload)))
493 {
494 return send_notify(this, AUTHENTICATION_FAILED);
495 }
496
497 switch (this->method)
498 {
499 case AUTH_XAUTH_INIT_PSK:
500 case AUTH_XAUTH_INIT_RSA:
501 case AUTH_HYBRID_INIT_RSA:
502 this->ike_sa->queue_task(this->ike_sa,
503 (task_t*)xauth_create(this->ike_sa, TRUE));
504 return SUCCESS;
505 case AUTH_XAUTH_RESP_PSK:
506 case AUTH_XAUTH_RESP_RSA:
507 case AUTH_HYBRID_RESP_RSA:
508 /* wait for XAUTH request */
509 break;
510 default:
511 if (charon->ike_sa_manager->check_uniqueness(
512 charon->ike_sa_manager, this->ike_sa, FALSE))
513 {
514 DBG1(DBG_IKE, "cancelling Main Mode due to uniqueness "
515 "policy");
516 return send_notify(this, AUTHENTICATION_FAILED);
517 }
518 if (!establish(this))
519 {
520 return send_notify(this, AUTHENTICATION_FAILED);
521 }
522 lib->processor->queue_job(lib->processor, (job_t*)
523 adopt_children_job_create(
524 this->ike_sa->get_id(this->ike_sa)));
525 break;
526 }
527 if (this->peer_cfg->get_pool(this->peer_cfg) == NULL &&
528 this->peer_cfg->get_virtual_ip(this->peer_cfg))
529 {
530 this->ike_sa->queue_task(this->ike_sa,
531 (task_t*)mode_config_create(this->ike_sa, TRUE));
532 }
533 return SUCCESS;
534 }
535 default:
536 return FAILED;
537 }
538 }
539
540 METHOD(task_t, process_i, status_t,
541 private_main_mode_t *this, message_t *message)
542 {
543 switch (this->state)
544 {
545 case MM_SA:
546 {
547 linked_list_t *list;
548 sa_payload_t *sa_payload;
549 auth_method_t method;
550 u_int32_t lifetime;
551 bool private;
552
553 sa_payload = (sa_payload_t*)message->get_payload(message,
554 SECURITY_ASSOCIATION_V1);
555 if (!sa_payload)
556 {
557 DBG1(DBG_IKE, "SA payload missing");
558 return send_notify(this, INVALID_PAYLOAD_TYPE);
559 }
560 list = sa_payload->get_proposals(sa_payload);
561 private = this->ike_sa->supports_extension(this->ike_sa,
562 EXT_STRONGSWAN);
563 this->proposal = this->ike_cfg->select_proposal(this->ike_cfg,
564 list, private);
565 list->destroy_offset(list, offsetof(proposal_t, destroy));
566 if (!this->proposal)
567 {
568 DBG1(DBG_IKE, "no proposal found");
569 return send_notify(this, NO_PROPOSAL_CHOSEN);
570 }
571 this->ike_sa->set_proposal(this->ike_sa, this->proposal);
572
573 lifetime = sa_payload->get_lifetime(sa_payload);
574 if (lifetime != this->lifetime)
575 {
576 DBG1(DBG_IKE, "received lifetime %us does not match configured "
577 "lifetime %us", lifetime, this->lifetime);
578 }
579 this->lifetime = lifetime;
580 method = sa_payload->get_auth_method(sa_payload);
581 if (method != this->method)
582 {
583 DBG1(DBG_IKE, "received %N authentication, but configured %N, "
584 "continue with configured", auth_method_names, method,
585 auth_method_names, this->method);
586 }
587 return NEED_MORE;
588 }
589 case MM_KE:
590 {
591 if (!this->ph1->get_nonce_ke(this->ph1, message))
592 {
593 return send_notify(this, INVALID_PAYLOAD_TYPE);
594 }
595 if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method))
596 {
597 return send_notify(this, INVALID_KEY_INFORMATION);
598 }
599 return NEED_MORE;
600 }
601 case MM_AUTH:
602 {
603 id_payload_t *id_payload;
604 identification_t *id, *cid;
605
606 id_payload = (id_payload_t*)message->get_payload(message, ID_V1);
607 if (!id_payload)
608 {
609 DBG1(DBG_IKE, "IDir payload missing");
610 return send_delete(this);
611 }
612 id = id_payload->get_identification(id_payload);
613 cid = this->ph1->get_id(this->ph1, this->peer_cfg, FALSE);
614 if (cid && !id->matches(id, cid))
615 {
616 DBG1(DBG_IKE, "IDir '%Y' does not match to '%Y'", id, cid);
617 id->destroy(id);
618 return send_delete(this);
619 }
620 this->ike_sa->set_other_id(this->ike_sa, id);
621
622 if (!this->ph1->verify_auth(this->ph1, this->method, message,
623 id_payload->get_encoded(id_payload)))
624 {
625 return send_delete(this);
626 }
627 if (!charon->bus->authorize(charon->bus, FALSE))
628 {
629 DBG1(DBG_IKE, "Main Mode authorization hook forbids IKE_SA, "
630 "cancelling");
631 return send_delete(this);
632 }
633
634 switch (this->method)
635 {
636 case AUTH_XAUTH_INIT_PSK:
637 case AUTH_XAUTH_INIT_RSA:
638 case AUTH_HYBRID_INIT_RSA:
639 /* wait for XAUTH request */
640 break;
641 case AUTH_XAUTH_RESP_PSK:
642 case AUTH_XAUTH_RESP_RSA:
643 case AUTH_HYBRID_RESP_RSA:
644 this->ike_sa->queue_task(this->ike_sa,
645 (task_t*)xauth_create(this->ike_sa, TRUE));
646 return SUCCESS;
647 default:
648 if (charon->ike_sa_manager->check_uniqueness(
649 charon->ike_sa_manager, this->ike_sa, FALSE))
650 {
651 DBG1(DBG_IKE, "cancelling Main Mode due to uniqueness "
652 "policy");
653 return send_delete(this);
654 }
655 if (!establish(this))
656 {
657 return send_delete(this);
658 }
659 break;
660 }
661 if (this->peer_cfg->get_virtual_ip(this->peer_cfg))
662 {
663 this->ike_sa->queue_task(this->ike_sa,
664 (task_t*)mode_config_create(this->ike_sa, TRUE));
665 }
666 return SUCCESS;
667 }
668 default:
669 return FAILED;
670 }
671 }
672
673 METHOD(task_t, get_type, task_type_t,
674 private_main_mode_t *this)
675 {
676 return TASK_MAIN_MODE;
677 }
678
679 METHOD(task_t, migrate, void,
680 private_main_mode_t *this, ike_sa_t *ike_sa)
681 {
682 DESTROY_IF(this->peer_cfg);
683 DESTROY_IF(this->proposal);
684 this->ph1->destroy(this->ph1);
685
686 this->ike_sa = ike_sa;
687 this->state = MM_INIT;
688 this->peer_cfg = NULL;
689 this->proposal = NULL;
690 this->ph1 = phase1_create(ike_sa, this->initiator);
691 }
692
693 METHOD(task_t, destroy, void,
694 private_main_mode_t *this)
695 {
696 DESTROY_IF(this->peer_cfg);
697 DESTROY_IF(this->proposal);
698 this->ph1->destroy(this->ph1);
699 free(this);
700 }
701
702 /*
703 * Described in header.
704 */
705 main_mode_t *main_mode_create(ike_sa_t *ike_sa, bool initiator)
706 {
707 private_main_mode_t *this;
708
709 INIT(this,
710 .public = {
711 .task = {
712 .get_type = _get_type,
713 .migrate = _migrate,
714 .destroy = _destroy,
715 },
716 },
717 .ike_sa = ike_sa,
718 .ph1 = phase1_create(ike_sa, initiator),
719 .initiator = initiator,
720 .state = MM_INIT,
721 );
722
723 if (initiator)
724 {
725 this->public.task.build = _build_i;
726 this->public.task.process = _process_i;
727 }
728 else
729 {
730 this->public.task.build = _build_r;
731 this->public.task.process = _process_r;
732 }
733
734 return &this->public;
735 }