]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libtnccs/plugins/tnccs_20/tnccs_20_handler.h
Implemented PB-TNC mutual half-duplex protocol
[thirdparty/strongswan.git] / src / libtnccs / plugins / tnccs_20 / tnccs_20_handler.h
1 /*
2 * Copyright (C) 2015 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 tnccs_20_handler_h tnccs_20_handler
18 * @{ @ingroup tnccs_20_handler
19 */
20
21 #ifndef TNCCS_20_HANDLER_H_
22 #define TNCCS_20_HANDLER_H_
23
24 #include <library.h>
25
26 #include "batch/pb_tnc_batch.h"
27 #include "messages/pb_tnc_msg.h"
28
29 typedef struct tnccs_20_handler_t tnccs_20_handler_t;
30
31 /**
32 * Interface for an IF-TNCCS 2.0 protocol handler
33 */
34 struct tnccs_20_handler_t {
35
36 /**
37 * Process content of received PB-TNC batch
38 *
39 * @param batch PB-TNC batch to be processed
40 * @return status
41 */
42 status_t (*process)(tnccs_20_handler_t *this, pb_tnc_batch_t *batch);
43
44 /**
45 * Build PB-TNC batch to be sent
46 *
47 * @param buf buffer to write PB-TNC batch to
48 * @param buflen size of buffer, receives bytes written
49 * @param msglen receives size of all PB-TNCH batch
50 * @return status
51 */
52 status_t (*build)(tnccs_20_handler_t *this, void *buf, size_t *buflen,
53 size_t *msglen);
54
55 /**
56 * Put the IMCs or IMVs into the handshake state
57 *
58 * @param mutual TRUE if PB-TNC mutual mode is already established
59 */
60 void (*begin_handshake)(tnccs_20_handler_t *this, bool mutual);
61
62 /**
63 * Indicates if IMCs or IMVs are allowed to send PA-TNC messages
64 *
65 * @return TRUE if allowed to send
66 */
67 bool (*get_send_flag)(tnccs_20_handler_t *this);
68
69 /**
70 * Indicates if the PB-TNC mutual protocol has been enabled
71 *
72 * @return TRUE if enabled
73 */
74 bool (*get_mutual)(tnccs_20_handler_t *this);
75
76 /**
77 * Get state of the PB-TNC protocol
78 *
79 * @return PB-TNC state
80 */
81 pb_tnc_state_t (*get_state)(tnccs_20_handler_t *this);
82
83 /**
84 * Add a PB-PA message to the handler's message queue
85 *
86 * @param msg PB-PA message to be added
87 */
88 void (*add_msg)(tnccs_20_handler_t *this, pb_tnc_msg_t *msg);
89
90 /**
91 * Handle errors that occurred during PB-TNC batch header processing
92 *
93 * @param batch batch where a fatal error occured
94 */
95 void (*handle_errors)(tnccs_20_handler_t *this, pb_tnc_batch_t *batch);
96
97 /**
98 * Destroys a tnccs_20_handler_t object.
99 */
100 void (*destroy)(tnccs_20_handler_t *this);
101 };
102
103 #endif /** TNCCS_20_HANDLER_H_ @}*/