2ff37983b90cc242f9bb49120fe533822ea839c1
[strongswan.git] / src / charon / sa / states / create_child_sa_requested.c
1 /**
2 * @file create_child_sa_requested.c
3 *
4 * @brief State after a CREATE_CHILD_SA request was sent.
5 *
6 */
7
8 /*
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include "create_child_sa_requested.h"
24
25 #include <sa/child_sa.h>
26 #include <encoding/payloads/ts_payload.h>
27 #include <encoding/payloads/sa_payload.h>
28 #include <encoding/payloads/nonce_payload.h>
29 #include <encoding/payloads/notify_payload.h>
30 #include <utils/logger_manager.h>
31
32
33 typedef struct private_create_child_sa_requested_t private_create_child_sa_requested_t;
34
35 /**
36 * Private data of a create_child_sa_requested_t object.
37 */
38 struct private_create_child_sa_requested_t {
39 /**
40 * Public interface of create_child_sa_requested_t.
41 */
42 create_child_sa_requested_t public;
43
44 /**
45 * Assigned IKE_SA.
46 */
47 protected_ike_sa_t *ike_sa;
48
49 /**
50 * nonce chosen by initiator
51 */
52 chunk_t nonce_i;
53
54 /**
55 * nonce chosen by the responder
56 */
57 chunk_t nonce_r;
58
59 /**
60 * Assigned logger.
61 *
62 * Is logger of ike_sa!
63 */
64 logger_t *logger;
65 };
66
67 /**
68 * Implements state_t.get_state
69 */
70 static status_t process_message(private_create_child_sa_requested_t *this, message_t *request)
71 {
72 this->logger->log(this->logger, ERROR, "NOT IMPLEMENTED");
73 }
74
75 /**
76 * Implements state_t.get_state
77 */
78 static ike_sa_state_t get_state(private_create_child_sa_requested_t *this)
79 {
80 return CREATE_CHILD_SA_REQUESTED;
81 }
82
83 /**
84 * Implementation of state_t.destroy.
85 */
86 static void destroy(private_create_child_sa_requested_t *this)
87 {
88 chunk_free(&this->nonce_i);
89 chunk_free(&this->nonce_r);
90 free(this);
91 }
92
93 /*
94 * Described in header.
95 */
96 create_child_sa_requested_t *create_child_sa_requested_create(protected_ike_sa_t *ike_sa, chunk_t nonce_i)
97 {
98 private_create_child_sa_requested_t *this = malloc_thing(private_create_child_sa_requested_t);
99
100 /* interface functions */
101 this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
102 this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
103 this->public.state_interface.destroy = (void (*) (state_t *)) destroy;
104
105 /* private data */
106 this->ike_sa = ike_sa;
107 this->nonce_i = nonce_i;
108 this->nonce_r = CHUNK_INITIALIZER;
109 this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
110
111 return &(this->public);
112 }