2 * Copyright (C) 2011 Martin Willi
3 * Copyright (C) 2011 revosec AG
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>.
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
16 #include "main_mode.h"
21 #include <crypto/diffie_hellman.h>
22 #include <encoding/payloads/sa_payload.h>
23 #include <encoding/payloads/ke_payload.h>
24 #include <encoding/payloads/nonce_payload.h>
27 typedef struct private_main_mode_t private_main_mode_t
;
30 * Private members of a main_mode_t task.
32 struct private_main_mode_t
{
35 * Public methods and task_t interface.
45 * Are we the initiator?
50 * IKE config to establish
55 METHOD(task_t
, build_i
, status_t
,
56 private_main_mode_t
*this, message_t
*message
)
58 /* TODO-IKEv1: initiate mainmode */
62 METHOD(task_t
, process_r
, status_t
,
63 private_main_mode_t
*this, message_t
*message
)
65 this->config
= this->ike_sa
->get_ike_cfg(this->ike_sa
);
66 DBG0(DBG_IKE
, "%H is initiating a Main Mode", message
->get_source(message
));
67 this->ike_sa
->set_state(this->ike_sa
, IKE_CONNECTING
);
69 /* TODO-IKEv1: process mainmode request */
73 METHOD(task_t
, build_r
, status_t
,
74 private_main_mode_t
*this, message_t
*message
)
76 /* TODO-IKEv1: build mainmode response */
80 METHOD(task_t
, process_i
, status_t
,
81 private_main_mode_t
*this, message_t
*message
)
83 /* TODO-IKEv1: process main mode as initiator */
87 METHOD(task_t
, get_type
, task_type_t
,
88 private_main_mode_t
*this)
93 METHOD(task_t
, migrate
, void,
94 private_main_mode_t
*this, ike_sa_t
*ike_sa
)
96 this->ike_sa
= ike_sa
;
99 METHOD(task_t
, destroy
, void,
100 private_main_mode_t
*this)
106 * Described in header.
108 main_mode_t
*main_mode_create(ike_sa_t
*ike_sa
, bool initiator
)
110 private_main_mode_t
*this;
115 .get_type
= _get_type
,
121 .initiator
= initiator
,
126 this->public.task
.build
= _build_i
;
127 this->public.task
.process
= _process_i
;
131 this->public.task
.build
= _build_r
;
132 this->public.task
.process
= _process_r
;
135 return &this->public;