2 * Copyright (C) 2010 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup pb_tnc_state_machine pb_tnc_state_machine
18 * @{ @ingroup tnccs_20
21 #ifndef PB_TNC_STATE_MACHINE_H_
22 #define PB_TNC_STATE_MACHINE_H_
24 typedef struct pb_tnc_state_machine_t pb_tnc_state_machine_t
;
25 typedef enum pb_tnc_state_t pb_tnc_state_t
;
27 #include "batch/pb_tnc_batch.h"
32 * PB-TNC States (state machine) as defined in section 3.2 of RFC 5793
36 PB_STATE_SERVER_WORKING
,
37 PB_STATE_CLIENT_WORKING
,
43 * enum name for pb_tnc_state_t.
45 extern enum_name_t
*pb_tnc_state_names
;
48 * Interface for the PB-TNC state machine.
50 struct pb_tnc_state_machine_t
{
53 * Get the current PB-TNC STATE
55 * @return current state
57 pb_tnc_state_t (*get_state
)(pb_tnc_state_machine_t
*this);
60 * Compute state transition due to received PB-TNC Batch
62 * @param type type of received batch
63 * @result TRUE if a valid transition was found, FALSE otherwise
65 bool (*receive_batch
)(pb_tnc_state_machine_t
*this, pb_tnc_batch_type_t type
);
68 * Compute state transition due to sent PB-TNC Batch
70 * @param type type of sent batch
71 * @result TRUE if a valid transition was found, FALSE otherwise
73 bool (*send_batch
)(pb_tnc_state_machine_t
*this, pb_tnc_batch_type_t type
);
76 * Informs whether the last received PB-TNC CDATA Batch was empty
78 * @result TRUE if last received PB-TNC CDATA Batch was empty
80 bool (*get_empty_cdata
)(pb_tnc_state_machine_t
*this);
83 * Store information whether the received PB-TNC CDATA Batch was empty
85 * @param empty set to TRUE if received PB-TNC CDATA Batch was empty
87 void (*set_empty_cdata
)(pb_tnc_state_machine_t
*this, bool empty
);
90 * Destroys a pb_tnc_state_machine_t object.
92 void (*destroy
)(pb_tnc_state_machine_t
*this);
96 * Create and initialize a PB-TNC state machine
98 * @param is_server TRUE if PB-TNC server, FALSE if PB-TNC client
100 pb_tnc_state_machine_t
* pb_tnc_state_machine_create(bool is_server
);
102 #endif /** PB_TNC_STATE_MACHINE_H_ @}*/