pb_tnc_batch_t class implements parsing and building of PB-TNC batches
[strongswan.git] / src / libcharon / plugins / tnccs_20 / messages / pb_error_message.h
1 /*
2 * Copyright (C) 2010 Sansar Choinyambuu
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_error_message pb_error_message
18 * @{ @ingroup tnccs_20
19 */
20
21 #ifndef PB_ERROR_MESSAGE_H_
22 #define PB_ERROR_MESSAGE_H_
23
24 #include "pb_tnc_message.h"
25
26 typedef enum pb_tnc_error_code_t pb_tnc_error_code_t;
27 typedef struct pb_error_message_t pb_error_message_t;
28
29 /**
30 * PB-TNC Error Codes as defined in section 4.9.1 of RFC 5793
31 */
32 enum pb_tnc_error_code_t {
33 PB_ERROR_UNEXPECTED_BATCH_TYPE = 0,
34 PB_ERROR_INVALID_PARAMETER = 1,
35 PB_ERROR_LOCAL_ERROR = 2,
36 PB_ERROR_UNSUPPORTED_MANDATORY_MESSAGE = 3,
37 PB_ERROR_VERSION_NOT_SUPPORTED = 4
38 };
39
40 /**
41 * enum name for pb_tnc_error_code_t.
42 */
43 extern enum_name_t *pb_tnc_error_code_names;
44
45 /**
46 * Classs representing the PB-Error message type.
47 */
48 struct pb_error_message_t {
49
50 /**
51 * PB-TNC Message interface
52 */
53 pb_tnc_message_t pb_interface;
54
55 /**
56 * Get the fatal flag
57 *
58 * @return fatal flag
59 */
60 bool (*get_fatal_flag)(pb_error_message_t *this);
61
62 /**
63 * Get PB Error code Vendor ID
64 *
65 * @return PB Error Code Vendor ID
66 */
67 u_int32_t (*get_vendor_id)(pb_error_message_t *this);
68
69 /**
70 * Get PB Error Code
71 *
72 * @return PB Error Code
73 */
74 u_int16_t (*get_error_code)(pb_error_message_t *this);
75
76 /**
77 * Get the PB Error Offset
78 *
79 * @return PB Error Offset
80 */
81 u_int32_t (*get_offset)(pb_error_message_t *this);
82
83 /**
84 * Set the PB Error Offset
85 *
86 * @param offset PB Error Offset
87 */
88 void (*set_offset)(pb_error_message_t *this, u_int32_t offset);
89
90 /**
91 * Get the PB Bad Version
92 *
93 * @return PB Bad Version
94 */
95 u_int8_t (*get_bad_version)(pb_error_message_t *this);
96
97 /**
98 * Set the PB Bad Version
99 *
100 * @param version PB Bad Version
101 */
102 void (*set_bad_version)(pb_error_message_t *this, u_int8_t version);
103 };
104
105 /**
106 * Create a PB-Error message from parameters
107 *
108 * @param fatal fatal flag
109 * @param vendor_id Error Code Vendor ID
110 * @param error_code Error Code
111 */
112 pb_tnc_message_t* pb_error_message_create(bool fatal, u_int32_t vendor_id,
113 pb_tnc_error_code_t error_code);
114 /**
115 * Create an unprocessed PB-Error message from raw data
116 *
117 * @param data PB-Error message data
118 */
119 pb_tnc_message_t* pb_error_message_create_from_data(chunk_t data);
120
121 #endif /** PB_PA_MESSAGE_H_ @}*/