xfrmi: Move to a separate directory to fix monolithic build
[strongswan.git] / src / libimcv / pwg / pwg_attr.c
1 /*
2 * Copyright (C) 2015 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 "pwg_attr.h"
17
18 #include "generic/generic_attr_bool.h"
19 #include "generic/generic_attr_chunk.h"
20 #include "generic/generic_attr_string.h"
21 #include "ietf/ietf_attr_fwd_enabled.h"
22 #include "ietf/ietf_attr_port_filter.h"
23 #include "pwg/pwg_attr_vendor_smi_code.h"
24
25 ENUM_BEGIN(pwg_attr_names, PWG_HCD_ATTRS_NATURAL_LANG,
26 PWG_HCD_VENDOR_SMI_CODE,
27 "HCD AttributesNaturalLanguage",
28 "HCD MachineTypeModel",
29 "HCD VendorName",
30 "HCD VendorSMICode");
31 ENUM_NEXT(pwg_attr_names, PWG_HCD_DEFAULT_PWD_ENABLED,
32 PWG_HCD_FORWARDING_ENABLED,
33 PWG_HCD_VENDOR_SMI_CODE,
34 "HCD DefaultPasswordEnabled",
35 "HCD FirewallSetting",
36 "HCD ForwardingEnabled");
37 ENUM_NEXT(pwg_attr_names, PWG_HCD_PSTN_FAX_ENABLED,
38 PWG_HCD_PSTN_FAX_ENABLED,
39 PWG_HCD_FORWARDING_ENABLED,
40 "HCD PSTNFaxEnabled");
41 ENUM_NEXT(pwg_attr_names, PWG_HCD_TIME_SOURCE,
42 PWG_HCD_TIME_SOURCE,
43 PWG_HCD_PSTN_FAX_ENABLED,
44 "HCD TimeSource");
45 ENUM_NEXT(pwg_attr_names, PWG_HCD_FIRMWARE_NAME,
46 PWG_HCD_FIRMWARE_VERSION,
47 PWG_HCD_TIME_SOURCE,
48 "HCD FirmwareName",
49 "HCD FirmwarePatches",
50 "HCD FirmwareStringVersion",
51 "HCD FirmwareVersion");
52 ENUM_NEXT(pwg_attr_names, PWG_HCD_RESIDENT_APP_NAME,
53 PWG_HCD_RESIDENT_APP_VERSION,
54 PWG_HCD_FIRMWARE_VERSION,
55 "HCD ResidentApplicationName",
56 "HCD ResidentApplicationPatches",
57 "HCD ResidentApplicationStringVersion",
58 "HCD ResidentApplicationVersion");
59 ENUM_NEXT(pwg_attr_names, PWG_HCD_USER_APP_NAME,
60 PWG_HCD_USER_APP_PERSIST_ENABLED,
61 PWG_HCD_RESIDENT_APP_VERSION,
62 "HCD UserApplicationName",
63 "HCD UserApplicationPatches",
64 "HCD UserApplicationStringVersion",
65 "HCD UserApplicationVersion",
66 "HCD UserApplicationEnabled",
67 "HCD UserApplicationPersistenceEnabled");
68 ENUM_NEXT(pwg_attr_names, PWG_HCD_CERTIFICATION_STATE,
69 PWG_HCD_CONFIGURATION_STATE,
70 PWG_HCD_USER_APP_PERSIST_ENABLED,
71 "HCD CertificationState",
72 "HCD ConfigurationState");
73 ENUM_END(pwg_attr_names, PWG_HCD_CONFIGURATION_STATE);
74
75 /**
76 * See header
77 */
78 pa_tnc_attr_t* pwg_attr_create_from_data(uint32_t type, size_t length, chunk_t value)
79 {
80 switch (type)
81 {
82 case PWG_HCD_DEFAULT_PWD_ENABLED:
83 case PWG_HCD_USER_APP_ENABLED:
84 case PWG_HCD_USER_APP_PERSIST_ENABLED:
85 case PWG_HCD_PSTN_FAX_ENABLED:
86 return generic_attr_bool_create_from_data(length, value,
87 pen_type_create(PEN_PWG, type));
88 case PWG_HCD_ATTRS_NATURAL_LANG:
89 case PWG_HCD_MACHINE_TYPE_MODEL:
90 case PWG_HCD_VENDOR_NAME:
91 case PWG_HCD_FIRMWARE_NAME:
92 case PWG_HCD_FIRMWARE_PATCHES:
93 case PWG_HCD_FIRMWARE_STRING_VERSION:
94 case PWG_HCD_TIME_SOURCE:
95 case PWG_HCD_USER_APP_NAME:
96 case PWG_HCD_USER_APP_PATCHES:
97 case PWG_HCD_USER_APP_STRING_VERSION:
98 case PWG_HCD_RESIDENT_APP_NAME:
99 case PWG_HCD_RESIDENT_APP_PATCHES:
100 case PWG_HCD_RESIDENT_APP_STRING_VERSION:
101 return generic_attr_string_create_from_data(length, value,
102 pen_type_create(PEN_PWG, type));
103 case PWG_HCD_FIRMWARE_VERSION:
104 case PWG_HCD_RESIDENT_APP_VERSION:
105 case PWG_HCD_USER_APP_VERSION:
106 return generic_attr_chunk_create_from_data(length, value, 16,
107 pen_type_create(PEN_PWG, type));
108 case PWG_HCD_CERTIFICATION_STATE:
109 case PWG_HCD_CONFIGURATION_STATE:
110 return generic_attr_chunk_create_from_data(length, value, 0,
111 pen_type_create(PEN_PWG, type));
112 case PWG_HCD_VENDOR_SMI_CODE:
113 return pwg_attr_vendor_smi_code_create_from_data(length, value);
114 case PWG_HCD_FORWARDING_ENABLED:
115 return ietf_attr_fwd_enabled_create_from_data(length, value,
116 pen_type_create(PEN_PWG, type));
117 case PWG_HCD_FIREWALL_SETTING:
118 return ietf_attr_port_filter_create_from_data(length, value,
119 pen_type_create(PEN_PWG, type));
120 default:
121 return NULL;
122 }
123 }