074bd11c7cc91ce6a44f9711d66763119af595b0
[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 "generic/generic_attr_bool.h"
29
30
31 ENUM_BEGIN(ietf_attr_names, IETF_ATTR_TESTING,
32 IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED,
33 "Testing",
34 "Attribute Request",
35 "Product Information",
36 "Numeric Version",
37 "String Version",
38 "Operational Status",
39 "Port Filter",
40 "Installed Packages",
41 "PA-TNC Error",
42 "Assessment Result",
43 "Remediation Instructions",
44 "Forwarding Enabled",
45 "Factory Default Password Enabled",
46 );
47 ENUM_NEXT(ietf_attr_names, IETF_ATTR_SW_REQUEST,
48 IETF_ATTR_SRC_METADATA_RESP,
49 IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED,
50 "SW Request",
51 "SW Identifier Inventory",
52 "SW Identifier Events",
53 "SW Inventory",
54 "SW Events",
55 "SW Subscription Status Request",
56 "SW Subscription Status Response",
57 "SW Source Metadata Request",
58 "SW Source Metadata Response",
59 );
60 ENUM_END(ietf_attr_names, IETF_ATTR_SRC_METADATA_RESP);
61
62 /**
63 * See header
64 */
65 pa_tnc_attr_t* ietf_attr_create_from_data(uint32_t type, size_t length,
66 chunk_t value)
67 {
68 switch (type)
69 {
70 case IETF_ATTR_ATTRIBUTE_REQUEST:
71 return ietf_attr_attr_request_create_from_data(length, value);
72 case IETF_ATTR_PRODUCT_INFORMATION:
73 return ietf_attr_product_info_create_from_data(length, value);
74 case IETF_ATTR_NUMERIC_VERSION:
75 return ietf_attr_numeric_version_create_from_data(length, value);
76 case IETF_ATTR_STRING_VERSION:
77 return ietf_attr_string_version_create_from_data(length, value);
78 case IETF_ATTR_OPERATIONAL_STATUS:
79 return ietf_attr_op_status_create_from_data(length, value);
80 case IETF_ATTR_PORT_FILTER:
81 return ietf_attr_port_filter_create_from_data(length, value,
82 pen_type_create(PEN_IETF, type));
83 case IETF_ATTR_INSTALLED_PACKAGES:
84 return ietf_attr_installed_packages_create_from_data(length, value);
85 case IETF_ATTR_PA_TNC_ERROR:
86 return ietf_attr_pa_tnc_error_create_from_data(length, value);
87 case IETF_ATTR_ASSESSMENT_RESULT:
88 return ietf_attr_assess_result_create_from_data(length, value);
89 case IETF_ATTR_REMEDIATION_INSTRUCTIONS:
90 return ietf_attr_remediation_instr_create_from_data(length, value);
91 case IETF_ATTR_FORWARDING_ENABLED:
92 return ietf_attr_fwd_enabled_create_from_data(length, value,
93 pen_type_create(PEN_IETF, type));
94 case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
95 return generic_attr_bool_create_from_data(length, value,
96 pen_type_create(PEN_IETF, type));
97 case IETF_ATTR_TESTING:
98 case IETF_ATTR_RESERVED:
99 /* unsupported IETF/SWIMA attributes */
100 case IETF_ATTR_SW_REQUEST:
101 case IETF_ATTR_SW_ID_INVENTORY:
102 case IETF_ATTR_SW_ID_EVENTS:
103 case IETF_ATTR_SW_INVENTORY:
104 case IETF_ATTR_SW_EVENTS:
105 case IETF_ATTR_SUBSCRIPTION_STATUS_REQ:
106 case IETF_ATTR_SUBSCRIPTION_STATUS_RESP:
107 case IETF_ATTR_SRC_METADATA_REQ:
108 case IETF_ATTR_SRC_METADATA_RESP:
109 default:
110 return NULL;
111 }
112 }