libimcv: Implemented IETF SW PA-TNC attributes
[strongswan.git] / src / libimcv / ietf / ietf_attr.c
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 #include "ietf_attr.h"
17 #include "ietf/ietf_attr_assess_result.h"
18 #include "ietf/ietf_attr_attr_request.h"
19 #include "ietf/ietf_attr_fwd_enabled.h"
20 #include "ietf/ietf_attr_installed_packages.h"
21 #include "ietf/ietf_attr_numeric_version.h"
22 #include "ietf/ietf_attr_op_status.h"
23 #include "ietf/ietf_attr_pa_tnc_error.h"
24 #include "ietf/ietf_attr_port_filter.h"
25 #include "ietf/ietf_attr_product_info.h"
26 #include "ietf/ietf_attr_remediation_instr.h"
27 #include "ietf/ietf_attr_string_version.h"
28 #include "ietf/swima/ietf_swima_attr_req.h"
29 #include "ietf/swima/ietf_swima_attr_sw_inv.h"
30 #include "ietf/swima/ietf_swima_attr_sw_ev.h"
31 #include "generic/generic_attr_bool.h"
32
33
34 ENUM_BEGIN(ietf_attr_names, IETF_ATTR_TESTING,
35 IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED,
36 "Testing",
37 "Attribute Request",
38 "Product Information",
39 "Numeric Version",
40 "String Version",
41 "Operational Status",
42 "Port Filter",
43 "Installed Packages",
44 "PA-TNC Error",
45 "Assessment Result",
46 "Remediation Instructions",
47 "Forwarding Enabled",
48 "Factory Default Password Enabled",
49 );
50 ENUM_NEXT(ietf_attr_names, IETF_ATTR_SW_REQUEST,
51 IETF_ATTR_SRC_METADATA_RESP,
52 IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED,
53 "SW Request",
54 "SW Identifier Inventory",
55 "SW Identifier Events",
56 "SW Inventory",
57 "SW Events",
58 "SW Subscription Status Request",
59 "SW Subscription Status Response",
60 "SW Source Metadata Request",
61 "SW Source Metadata Response",
62 );
63 ENUM_END(ietf_attr_names, IETF_ATTR_SRC_METADATA_RESP);
64
65 /**
66 * See header
67 */
68 pa_tnc_attr_t* ietf_attr_create_from_data(uint32_t type, size_t length,
69 chunk_t value)
70 {
71 switch (type)
72 {
73 case IETF_ATTR_ATTRIBUTE_REQUEST:
74 return ietf_attr_attr_request_create_from_data(length, value);
75 case IETF_ATTR_PRODUCT_INFORMATION:
76 return ietf_attr_product_info_create_from_data(length, value);
77 case IETF_ATTR_NUMERIC_VERSION:
78 return ietf_attr_numeric_version_create_from_data(length, value);
79 case IETF_ATTR_STRING_VERSION:
80 return ietf_attr_string_version_create_from_data(length, value);
81 case IETF_ATTR_OPERATIONAL_STATUS:
82 return ietf_attr_op_status_create_from_data(length, value);
83 case IETF_ATTR_PORT_FILTER:
84 return ietf_attr_port_filter_create_from_data(length, value,
85 pen_type_create(PEN_IETF, type));
86 case IETF_ATTR_INSTALLED_PACKAGES:
87 return ietf_attr_installed_packages_create_from_data(length, value);
88 case IETF_ATTR_PA_TNC_ERROR:
89 return ietf_attr_pa_tnc_error_create_from_data(length, value);
90 case IETF_ATTR_ASSESSMENT_RESULT:
91 return ietf_attr_assess_result_create_from_data(length, value);
92 case IETF_ATTR_REMEDIATION_INSTRUCTIONS:
93 return ietf_attr_remediation_instr_create_from_data(length, value);
94 case IETF_ATTR_FORWARDING_ENABLED:
95 return ietf_attr_fwd_enabled_create_from_data(length, value,
96 pen_type_create(PEN_IETF, type));
97 case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
98 return generic_attr_bool_create_from_data(length, value,
99 pen_type_create(PEN_IETF, type));
100 case IETF_ATTR_SW_REQUEST:
101 return ietf_swima_attr_req_create_from_data(length, value);
102 case IETF_ATTR_SW_ID_INVENTORY:
103 return ietf_swima_attr_sw_inv_create_from_data(length, value, TRUE);
104 case IETF_ATTR_SW_INVENTORY:
105 return ietf_swima_attr_sw_inv_create_from_data(length, value, FALSE);
106 case IETF_ATTR_SW_ID_EVENTS:
107 return ietf_swima_attr_sw_ev_create_from_data(length, value, TRUE);
108 case IETF_ATTR_SW_EVENTS:
109 return ietf_swima_attr_sw_ev_create_from_data(length, value, FALSE);
110 case IETF_ATTR_TESTING:
111 case IETF_ATTR_RESERVED:
112 /* unsupported IETF/SWIMA attributes */
113 case IETF_ATTR_SUBSCRIPTION_STATUS_REQ:
114 case IETF_ATTR_SUBSCRIPTION_STATUS_RESP:
115 case IETF_ATTR_SRC_METADATA_REQ:
116 case IETF_ATTR_SRC_METADATA_RESP:
117 default:
118 return NULL;
119 }
120 }