summaryrefslogtreecommitdiff
path: root/src/libimcv/pwg/pwg_attr.c
blob: 8a2eb2828883e82a2c55a8c9e41c0f9443be51b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * Copyright (C) 2015 Andreas Steffen
 * HSR Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

#include "pwg_attr.h"

#include "generic/generic_attr_bool.h"
#include "generic/generic_attr_chunk.h"
#include "generic/generic_attr_string.h"
#include "ietf/ietf_attr_fwd_enabled.h"
#include "ietf/ietf_attr_port_filter.h"
#include "pwg/pwg_attr_vendor_smi_code.h"

ENUM_BEGIN(pwg_attr_names,	PWG_HCD_ATTRS_NATURAL_LANG,
							PWG_HCD_VENDOR_SMI_CODE,
	"HCD AttributesNaturalLanguage",
	"HCD MachineTypeModel",
	"HCD VendorName",
	"HCD VendorSMICode");
ENUM_NEXT(pwg_attr_names,	PWG_HCD_DEFAULT_PWD_ENABLED,
							PWG_HCD_FORWARDING_ENABLED,
							PWG_HCD_VENDOR_SMI_CODE,
	"HCD DefaultPasswordEnabled",
	"HCD FirewallSetting",
	"HCD ForwardingEnabled");
ENUM_NEXT(pwg_attr_names,	PWG_HCD_PSTN_FAX_ENABLED,
							PWG_HCD_PSTN_FAX_ENABLED,
							PWG_HCD_FORWARDING_ENABLED,
	"HCD PSTNFaxEnabled");
ENUM_NEXT(pwg_attr_names,	PWG_HCD_TIME_SOURCE,
							PWG_HCD_TIME_SOURCE,
							PWG_HCD_PSTN_FAX_ENABLED,
	"HCD TimeSource");
ENUM_NEXT(pwg_attr_names,	PWG_HCD_FIRMWARE_NAME,
							PWG_HCD_FIRMWARE_VERSION,
							PWG_HCD_TIME_SOURCE,
	"HCD FirmwareName",
	"HCD FirmwarePatches",
	"HCD FirmwareStringVersion",
	"HCD FirmwareVersion");
ENUM_NEXT(pwg_attr_names,	PWG_HCD_RESIDENT_APP_NAME,
							PWG_HCD_RESIDENT_APP_VERSION,
							PWG_HCD_FIRMWARE_VERSION,
	"HCD ResidentApplicationName",
	"HCD ResidentApplicationPatches",
	"HCD ResidentApplicationStringVersion",
	"HCD ResidentApplicationVersion");
ENUM_NEXT(pwg_attr_names,	PWG_HCD_USER_APP_NAME,
							PWG_HCD_USER_APP_PERSIST_ENABLED,
							PWG_HCD_RESIDENT_APP_VERSION,
	"HCD UserApplicationName",
	"HCD UserApplicationPatches",
	"HCD UserApplicationStringVersion",
	"HCD UserApplicationVersion",
	"HCD UserApplicationEnabled",
	"HCD UserApplicationPersistenceEnabled");
ENUM_NEXT(pwg_attr_names,	PWG_HCD_CERTIFICATION_STATE,
							PWG_HCD_CONFIGURATION_STATE,
							PWG_HCD_USER_APP_PERSIST_ENABLED,
	"HCD CertificationState",
	"HCD ConfigurationState");
ENUM_END(pwg_attr_names,	PWG_HCD_CONFIGURATION_STATE);

/**
 * See header
 */
pa_tnc_attr_t* pwg_attr_create_from_data(u_int32_t type, size_t length, chunk_t value)
{
	switch (type)
	{
		case PWG_HCD_DEFAULT_PWD_ENABLED:
		case PWG_HCD_USER_APP_ENABLED:
		case PWG_HCD_USER_APP_PERSIST_ENABLED:
		case PWG_HCD_PSTN_FAX_ENABLED:
			return generic_attr_bool_create_from_data(length, value,
									pen_type_create(PEN_PWG, type));
		case PWG_HCD_ATTRS_NATURAL_LANG:
		case PWG_HCD_MACHINE_TYPE_MODEL:
		case PWG_HCD_VENDOR_NAME:
		case PWG_HCD_FIRMWARE_NAME:
		case PWG_HCD_FIRMWARE_PATCHES:
		case PWG_HCD_FIRMWARE_STRING_VERSION:
		case PWG_HCD_TIME_SOURCE:
		case PWG_HCD_USER_APP_NAME:
		case PWG_HCD_USER_APP_PATCHES:
		case PWG_HCD_USER_APP_STRING_VERSION:
		case PWG_HCD_RESIDENT_APP_NAME:
		case PWG_HCD_RESIDENT_APP_PATCHES:
		case PWG_HCD_RESIDENT_APP_STRING_VERSION:
			return generic_attr_string_create_from_data(length, value,
									pen_type_create(PEN_PWG, type));
		case PWG_HCD_FIRMWARE_VERSION:
		case PWG_HCD_RESIDENT_APP_VERSION:
		case PWG_HCD_USER_APP_VERSION:
			return generic_attr_chunk_create_from_data(length, value, 16,
									pen_type_create(PEN_PWG, type));
		case PWG_HCD_CERTIFICATION_STATE:
		case PWG_HCD_CONFIGURATION_STATE:
			return generic_attr_chunk_create_from_data(length, value, 0,
									pen_type_create(PEN_PWG, type));
		case PWG_HCD_VENDOR_SMI_CODE:
			return pwg_attr_vendor_smi_code_create_from_data(length, value);
		case PWG_HCD_FORWARDING_ENABLED:
			return ietf_attr_fwd_enabled_create_from_data(length, value,
									pen_type_create(PEN_PWG, type));
		case PWG_HCD_FIREWALL_SETTING:
			return ietf_attr_port_filter_create_from_data(length, value,
									pen_type_create(PEN_PWG, type));
		default:
			return NULL;
	}
}