(no commit message)
[strongswan.git] / Source / charon / states / initiator_init.c
1 /**
2 * @file initiator_init.c
3 *
4 * @brief Start state of a IKE_SA as initiator
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 "initiator_init.h"
24
25 #include "../utils/allocator.h"
26
27 /**
28 * Private data of a initiator_init_t object.
29 *
30 */
31 typedef struct private_initiator_init_s private_initiator_init_t;
32 struct private_initiator_init_s {
33 /**
34 * methods of the state_t interface
35 */
36 initiator_init_t public;
37
38 };
39
40 static status_t initiate_connection (private_initiator_init_t *this, char *name, state_t **new_state)
41 {
42 return SUCCESS;
43 }
44
45 /**
46 * Implements state_t.get_state
47 */
48 static status_t process_message(private_initiator_init_t *this, message_t *message, state_t **new_state)
49 {
50 *new_state = (state_t *) this;
51 return FAILED;
52 }
53
54 /**
55 * Implements state_t.get_state
56 */
57 static ike_sa_state_t get_state(private_initiator_init_t *this)
58 {
59 return INITIATOR_INIT;
60 }
61
62 /**
63 * Implements state_t.get_state
64 */
65 static status_t destroy(private_initiator_init_t *this)
66 {
67 allocator_free(this);
68 return SUCCESS;
69 }
70
71 /*
72 * Described in header.
73 */
74 initiator_init_t *initiator_init_create()
75 {
76 private_initiator_init_t *this = allocator_alloc_thing(private_initiator_init_t);
77
78 if (this == NULL)
79 {
80 return NULL;
81 }
82
83 /* interface functions */
84 this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *,state_t **)) process_message;
85 this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
86 this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
87
88 /* public functions */
89 this->public.initiate_connection = (status_t (*)(initiator_init_t *, char *, state_t **)) initiate_connection;
90
91 return &(this->public);
92 }