current state
[strongswan.git] / Source / charon / states / ike_sa_init_responded.c
1 /**
2 * @file ike_sa_init_responded.c
3 *
4 * @brief State of a IKE_SA after responding to an IKE_SA_INIT request
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, 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 "ike_sa_init_responded.h"
24
25 #include "../utils/allocator.h"
26
27 /**
28 * Private data of a ike_sa_init_responded_t object.
29 *
30 */
31 typedef struct private_ike_sa_init_responded_s private_ike_sa_init_responded_t;
32 struct private_ike_sa_init_responded_s {
33 /**
34 * methods of the state_t interface
35 */
36 ike_sa_init_responded_t public;
37
38 /**
39 * Assigned IKE_SA
40 */
41 protected_ike_sa_t *ike_sa;
42 };
43
44 /**
45 * Implements state_t.get_state
46 */
47 static status_t process_message(private_ike_sa_init_responded_t *this, message_t *message, state_t **new_state)
48 {
49 *new_state = (state_t *) this;
50 return SUCCESS;
51 }
52
53 /**
54 * Implements state_t.get_state
55 */
56 static ike_sa_state_t get_state(private_ike_sa_init_responded_t *this)
57 {
58 return IKE_SA_INIT_RESPONDED;
59 }
60
61 /**
62 * Implements state_t.get_state
63 */
64 static status_t destroy(private_ike_sa_init_responded_t *this)
65 {
66 allocator_free(this);
67 return SUCCESS;
68 }
69
70 /*
71 * Described in header.
72 */
73 ike_sa_init_responded_t *ike_sa_init_responded_create(protected_ike_sa_t *ike_sa)
74 {
75 private_ike_sa_init_responded_t *this = allocator_alloc_thing(private_ike_sa_init_responded_t);
76
77 if (this == NULL)
78 {
79 return NULL;
80 }
81
82 /* interface functions */
83 this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
84 this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
85 this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
86
87 /* private data */
88 this->ike_sa = ike_sa;
89
90 return &(this->public);
91 }