define pb_tnc_state_machine_t object
[strongswan.git] / src / libcharon / plugins / tnccs_20 / state_machine / pb_tnc_state_machine.h
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup pb_tnc_state_machine pb_tnc_state_machine
18 * @{ @ingroup tnccs_20
19 */
20
21 #ifndef PB_TNC_STATE_MACHINE_H_
22 #define PB_TNC_STATE_MACHINE_H_
23
24 typedef struct pb_tnc_state_machine_t pb_tnc_state_machine_t;
25 typedef enum pb_tnc_state_t pb_tnc_state_t;
26
27 #include "batch/pb_tnc_batch.h"
28
29 #include <library.h>
30
31 /**
32 * PB-TNC States (state machine) as defined in section 3.2 of RFC 5793
33 */
34 enum pb_tnc_state_t {
35 PB_STATE_INIT,
36 PB_STATE_SERVER_WORKING,
37 PB_STATE_CLIENT_WORKING,
38 PB_STATE_DECIDED,
39 PB_STATE_END,
40 };
41
42 /**
43 * enum name for pb_tnc_state_t.
44 */
45 extern enum_name_t *pb_tnc_state_names;
46
47 /**
48 * Interface for the PB-TNC state machine.
49 */
50 struct pb_tnc_state_machine_t {
51
52 /**
53 * Get the current PB-TNC STATE
54 *
55 * @return current state
56 */
57 pb_tnc_state_t (*get_state)(pb_tnc_state_machine_t *this);
58
59 /**
60 * Compute state transition due to received PB-TNC Batch
61 *
62 * @param type type of received batch
63 * @result TRUE if a valid transition was found, FALSE otherwise
64 */
65 bool (*receive_batch)(pb_tnc_state_machine_t *this, pb_tnc_batch_type_t type);
66
67 /**
68 * Compute state transition due to sent PB-TNC Batch
69 *
70 * @param type type of sent batch
71 * @result TRUE if a valid transition was found, FALSE otherwise
72 */
73 bool (*send_batch)(pb_tnc_state_machine_t *this, pb_tnc_batch_type_t type);
74
75 /**
76 * Destroys a pb_tnc_state_machine_t object.
77 */
78 void (*destroy)(pb_tnc_state_machine_t *this);
79 };
80
81 /**
82 * Create and initialize a PB-TNC state machine
83 *
84 * @param is_server TRUE if PB-TNC server, FALSE if PB-TNC client
85 */
86 pb_tnc_state_machine_t* pb_tnc_state_machine_create(bool is_server);
87
88 #endif /** PB_TNC_STATE_MACHINE_H_ @}*/