- changed allocation behavior
[strongswan.git] / Source / charon / sa / states / ike_sa_established.c
1 /**
2 * @file ike_sa_established.c
3 *
4 * @brief Implementation of ike_sa_established_t.
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_established.h"
24
25 #include <utils/allocator.h>
26
27
28 typedef struct private_ike_sa_established_t private_ike_sa_established_t;
29
30 /**
31 * Private data of a ike_sa_established_t object.
32 */
33 struct private_ike_sa_established_t {
34 /**
35 * methods of the state_t interface
36 */
37 ike_sa_established_t public;
38
39 /**
40 * Assigned IKE_SA
41 */
42 protected_ike_sa_t *ike_sa;
43
44 };
45
46 /**
47 * Implements state_t.get_state
48 */
49 static status_t process_message(private_ike_sa_established_t *this, message_t *message)
50 {
51 return SUCCESS;
52 }
53
54 /**
55 * Implements state_t.get_state
56 */
57 static ike_sa_state_t get_state(private_ike_sa_established_t *this)
58 {
59 return IKE_SA_ESTABLISHED;
60 }
61
62 /**
63 * Implements state_t.get_state
64 */
65 static void destroy(private_ike_sa_established_t *this)
66 {
67 allocator_free(this);
68 }
69
70 /*
71 * Described in header.
72 */
73 ike_sa_established_t *ike_sa_established_create(protected_ike_sa_t *ike_sa)
74 {
75 private_ike_sa_established_t *this = allocator_alloc_thing(private_ike_sa_established_t);
76
77 /* interface functions */
78 this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
79 this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
80 this->public.state_interface.destroy = (void (*) (state_t *)) destroy;
81
82 /* private data */
83 this->ike_sa = ike_sa;
84
85 return &(this->public);
86 }