implemented PB-TNC message parsing checks
[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 /**
33 * PB-TNC Batch Types as defined in section 4.1 of RFC 5793
34 */
35 enum pb_tnc_batch_type_t {
36 PB_BATCH_CDATA = 1,
37 PB_BATCH_SDATA = 2,
38 PB_BATCH_RESULT = 3,
39 PB_BATCH_CRETRY = 4,
40 PB_BATCH_SRETRY = 5,
41 PB_BATCH_CLOSE = 6,
42 PB_BATCH_ROOF = 6
43 };
44
45 /**
46 * enum name for pb_tnc_batch_type_t.
47 */
48 extern enum_name_t *pb_tnc_batch_type_names;
49
50 /**
51 * Interface for all PB-TNC Batch Types.
52 */
53 struct pb_tnc_batch_t {
54
55 /**
56 * Get the PB-TNC Message Type
57 *
58 * @return PB-TNC batch type
59 */
60 pb_tnc_batch_type_t (*get_type)(pb_tnc_batch_t *this);
61
62 /**
63 * Get the encoding of the PB-TNC Batch
64 *
65 * @return encoded PB-TNC batch
66 */
67 chunk_t (*get_encoding)(pb_tnc_batch_t *this);
68
69 /**
70 * Add a PB-TNC Message
71 *
72 * @param msg PB-TNC message to be addedd
73 */
74 void (*add_msg)(pb_tnc_batch_t *this, pb_tnc_msg_t* msg);
75
76 /**
77 * Build the PB-TNC Batch
78 */
79 void (*build)(pb_tnc_batch_t *this);
80
81 /**
82 * Process the PB-TNC Batch
83 *
84 * @param PB-TNC state machine
85 * @return return processing status
86 */
87 status_t (*process)(pb_tnc_batch_t *this,
88 pb_tnc_state_machine_t *state_machine);
89
90 /**
91 * Enumerates over all PB-TNC Messages
92 *
93 * @return return message enumerator
94 */
95 enumerator_t* (*create_msg_enumerator)(pb_tnc_batch_t *this);
96
97 /**
98 * Enumerates over all parsing errors
99 *
100 * @return return error enumerator
101 */
102 enumerator_t* (*create_error_enumerator)(pb_tnc_batch_t *this);
103
104 /**
105 * Destroys a pb_tnc_batch_t object.
106 */
107 void (*destroy)(pb_tnc_batch_t *this);
108 };
109
110 /**
111 * Create an empty PB-TNC Batch of a given type
112 *
113 * @parame is_server TRUE if server, FALSE if client
114 * @param type PB-TNC batch type
115 */
116 pb_tnc_batch_t* pb_tnc_batch_create(bool is_server, pb_tnc_batch_type_t type);
117
118 /**
119 * Create an unprocessed PB-TNC Batch from data
120 *
121 * @parame is_server TRUE if server, FALSE if client
122 * @param data encoded PB-TNC batch
123 */
124 pb_tnc_batch_t* pb_tnc_batch_create_from_data(bool is_server, chunk_t data);
125
126 #endif /** PB_TNC_BATCH_H_ @}*/