(no commit message)
[strongswan.git] / Source / charon / states / state.h
1 /**
2 * @file state.h
3 *
4 * @brief Interface for a specific IKE_SA state
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 #ifndef STATE_H_
24 #define STATE_H_
25
26 #include "../definitions.h"
27 #include "../types.h"
28 #include "../message.h"
29
30 /**
31 * States in which a IKE_SA can actually be
32 */
33 typedef enum ike_sa_state_e ike_sa_state_t;
34
35 enum ike_sa_state_e {
36
37 /**
38 * IKE_SA is is not in a state as initiator
39 */
40 INITIATOR_INIT = 1,
41
42 /**
43 * IKE_SA is is not in a state as responder
44 */
45 RESPONDER_INIT = 2,
46
47 /**
48 * A IKE_SA_INIT-message was sent: role initiator
49 */
50 IKE_SA_INIT_REQUESTED = 3,
51
52 /**
53 * A IKE_SA_INIT-message was replied: role responder
54 */
55 IKE_SA_INIT_RESPONDED = 4,
56
57 /**
58 * An IKE_AUTH-message was sent after a successful
59 * IKE_SA_INIT-exchange: role initiator
60 */
61 IKE_AUTH_REQUESTED = 5,
62
63 /**
64 * An IKE_AUTH-message was replied: role responder.
65 * In this state, all the informations for an IKE_SA
66 * and one CHILD_SA are known.
67 */
68 IKE_SA_INITIALIZED = 6
69 };
70
71 /**
72 * @brief This interface represents an IKE_SA state
73 *
74 */
75 typedef struct state_s state_t;
76
77 struct state_s {
78
79 /**
80 * @brief Processes a incoming IKEv2-Message of type message_t
81 *
82 * @param this state_t object
83 * @param[in] message message_t object to process
84 * @param this state_t pointer to the new state_t object
85 * @return
86 * - SUCCESSFUL if succeeded
87 * - FAILED otherwise
88 */
89 status_t (*process_message) (state_t *this,message_t *message,state_t **new_state);
90
91
92 /**
93 * @brief Get the current state
94 *
95 * @param this state_t object
96 * @return state
97 */
98 ike_sa_state_t (*get_state) (state_t *this);
99
100 /**
101 * @brief Destroys a state_t object
102 *
103 * @param this state_t object
104 * @return SUCCESS in any case
105 */
106 status_t (*destroy) (state_t *this);
107 };
108
109
110 #endif /*STATE_H_*/