9a882763e5c15e0892bf07d61e0f2bcfa459618f
[strongswan.git] / src / libimcv / ietf / ietf_attr_pa_tnc_error.h
1 /*
2 * Copyright (C) 2011-2017 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 ietf_attr_pa_tnc_errort ietf_attr_pa_tnc_error
18 * @{ @ingroup ietf_attr
19 */
20
21 #ifndef IETF_ATTR_PA_TNC_ERROR_H_
22 #define IETF_ATTR_PA_TNC_ERROR_H_
23
24 typedef struct ietf_attr_pa_tnc_error_t ietf_attr_pa_tnc_error_t;
25 typedef enum pa_tnc_error_code_t pa_tnc_error_code_t;
26
27 #include "ietf_attr.h"
28 #include "pa_tnc/pa_tnc_attr.h"
29
30 /**
31 * IETF Standard PA-TNC Error Codes as defined in section 4.2.8 of RFC 5792
32 */
33 enum pa_tnc_error_code_t {
34
35 /* RFC 5792 PA-TNC */
36 PA_ERROR_RESERVED = 0,
37 PA_ERROR_INVALID_PARAMETER = 1,
38 PA_ERROR_VERSION_NOT_SUPPORTED = 2,
39 PA_ERROR_ATTR_TYPE_NOT_SUPPORTED = 3,
40
41 /* draft-ietf-sacm-nea-swid-patnc (SWIMA) */
42 PA_ERROR_SW = 32,
43 PA_ERROR_SW_SUBSCRIPTION_DENIED = 33,
44 PA_ERROR_SW_RESPONSE_TOO_LARGE = 34,
45 PA_ERROR_SW_SUBSCRIPTION_FULFILLMENT = 35,
46 PA_ERROR_SW_SUBSCRIPTION_ID_REUSE = 36
47 };
48
49 /**
50 * enum name for pa_tnc_error_code_t.
51 */
52 extern enum_name_t *pa_tnc_error_code_names;
53
54 /**
55 * Class implementing the IETF PA-TNC Error attribute.
56 *
57 */
58 struct ietf_attr_pa_tnc_error_t {
59
60 /**
61 * Public PA-TNC attribute interface
62 */
63 pa_tnc_attr_t pa_tnc_attribute;
64
65 /**
66 * Get Vendor-specific PA-TNC error code
67 *
68 * @return error code
69 */
70 pen_type_t (*get_error_code)(ietf_attr_pa_tnc_error_t *this);
71
72 /**
73 * Get first 8 bytes of erroneous PA-TNC message
74 *
75 * @return PA-TNC message info
76 */
77 chunk_t (*get_msg_info)(ietf_attr_pa_tnc_error_t *this);
78
79 /**
80 * Get flags, vendor ID and type of unsupported PA-TNC attribute
81 *
82 * @param flags PA-TNC attribute flags
83 * @return PA-TNC attribute vendor ID and type
84 */
85 pen_type_t (*get_unsupported_attr)(ietf_attr_pa_tnc_error_t *this,
86 uint8_t *flags);
87
88 /**
89 * Set flags, vendor ID and type of unsupported PA-TNC attribute
90 *
91 * @param flags PA-TNC attribute flags
92 * @param attr_info PA-TNC attribute vendor ID and type
93 */
94 void (*set_unsupported_attr)(ietf_attr_pa_tnc_error_t *this, uint8_t flags,
95 pen_type_t type);
96
97 /**
98 * Get the PA-TNC error offset
99 *
100 * @return PA-TNC error offset
101 */
102 uint32_t (*get_offset)(ietf_attr_pa_tnc_error_t *this);
103
104 };
105
106 /**
107 * Creates an ietf_attr_pa_tnc_error_t object from an error code
108 *
109 * @param error_code Vendor-specific PA-TNC error code
110 * @param header PA-TNC message header (first 8 bytes)
111 *
112 */
113 pa_tnc_attr_t* ietf_attr_pa_tnc_error_create(pen_type_t error_code,
114 chunk_t header);
115
116 /**
117 * Creates an ietf_attr_pa_tnc_error_t object from an error code with offset
118 *
119 * @param error_code Vendor-specifica PA-TNC error code
120 * @param header PA-TNC message header (first 8 bytes)
121 * @param error_offset PA-TNC error offset in bytes
122 *
123 */
124 pa_tnc_attr_t* ietf_attr_pa_tnc_error_create_with_offset(pen_type_t error_code,
125 chunk_t header,
126 uint32_t error_offset);
127
128 /**
129 * Creates an ietf_attr_pa_tnc_error_t object from received data
130 *
131 * @param length Total length of attribute value
132 * @param value Unparsed attribute value (might be a segment)
133 */
134 pa_tnc_attr_t* ietf_attr_pa_tnc_error_create_from_data(size_t length,
135 chunk_t value);
136
137 #endif /** IETF_ATTR_PA_TNC_ERROR_H_ @}*/