limit the size of a PB-TNC batch to the maximum EAP-TNC packet size
[strongswan.git] / src / libcharon / plugins / tnccs_20 / batch / pb_tnc_batch.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_batch pb_tnc_batch
18 * @{ @ingroup tnccs_20
19 */
20
21 #ifndef PB_TNC_BATCH_H_
22 #define PB_TNC_BATCH_H_
23
24 typedef enum pb_tnc_batch_type_t pb_tnc_batch_type_t;
25 typedef struct pb_tnc_batch_t pb_tnc_batch_t;
26
27 #include "messages/pb_tnc_msg.h"
28 #include "state_machine/pb_tnc_state_machine.h"
29
30 #include <library.h>
31
32 #define PB_TNC_BATCH_HEADER_SIZE 8
33 #define PB_TNC_HEADER_SIZE 12
34
35 /**
36 * PB-TNC Batch Types as defined in section 4.1 of RFC 5793
37 */
38 enum pb_tnc_batch_type_t {
39 PB_BATCH_NONE = 0, /* for internal use only */
40 PB_BATCH_CDATA = 1,
41 PB_BATCH_SDATA = 2,
42 PB_BATCH_RESULT = 3,
43 PB_BATCH_CRETRY = 4,
44 PB_BATCH_SRETRY = 5,
45 PB_BATCH_CLOSE = 6,
46 PB_BATCH_ROOF = 6
47 };
48
49 /**
50 * enum name for pb_tnc_batch_type_t.
51 */
52 extern enum_name_t *pb_tnc_batch_type_names;
53
54 /**
55 * Interface for all PB-TNC Batch Types.
56 */
57 struct pb_tnc_batch_t {
58
59 /**
60 * Get the PB-TNC Message Type
61 *
62 * @return PB-TNC batch type
63 */
64 pb_tnc_batch_type_t (*get_type)(pb_tnc_batch_t *this);
65
66 /**
67 * Get the encoding of the PB-TNC Batch
68 *
69 * @return encoded PB-TNC batch
70 */
71 chunk_t (*get_encoding)(pb_tnc_batch_t *this);
72
73 /**
74 * Add a PB-TNC Message
75 *
76 * @param msg PB-TNC message to be addedd
77 */
78 void (*add_msg)(pb_tnc_batch_t *this, pb_tnc_msg_t* msg);
79
80 /**
81 * Build the PB-TNC Batch
82 */
83 void (*build)(pb_tnc_batch_t *this);
84
85 /**
86 * Process the PB-TNC Batch
87 *
88 * @param PB-TNC state machine
89 * @return return processing status
90 */
91 status_t (*process)(pb_tnc_batch_t *this,
92 pb_tnc_state_machine_t *state_machine);
93
94 /**
95 * Enumerates over all PB-TNC Messages
96 *
97 * @return return message enumerator
98 */
99 enumerator_t* (*create_msg_enumerator)(pb_tnc_batch_t *this);
100
101 /**
102 * Enumerates over all parsing errors
103 *
104 * @return return error enumerator
105 */
106 enumerator_t* (*create_error_enumerator)(pb_tnc_batch_t *this);
107
108 /**
109 * Destroys a pb_tnc_batch_t object.
110 */
111 void (*destroy)(pb_tnc_batch_t *this);
112 };
113
114 /**
115 * Create an empty PB-TNC Batch of a given type
116 *
117 * @param is_server TRUE if server, FALSE if client
118 * @param type PB-TNC batch type
119 */
120 pb_tnc_batch_t* pb_tnc_batch_create(bool is_server, pb_tnc_batch_type_t type);
121
122 /**
123 * Create an unprocessed PB-TNC Batch from data
124 *
125 * @param is_server TRUE if server, FALSE if client
126 * @param data encoded PB-TNC batch
127 */
128 pb_tnc_batch_t* pb_tnc_batch_create_from_data(bool is_server, chunk_t data);
129
130 #endif /** PB_TNC_BATCH_H_ @}*/