1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROMEOS_NETWORK_ONC_ONC_SIGNATURE_H_
6 #define CHROMEOS_NETWORK_ONC_ONC_SIGNATURE_H_
7 
8 #include <string>
9 
10 #include "base/component_export.h"
11 #include "base/values.h"
12 
13 namespace chromeos {
14 namespace onc {
15 
16 // Generates a default value for a field.
17 // This is used so that static global base::Values can be avoided (which would
18 // have a non-trivial destructor and are thus prohibited).
19 using DefaultValueSetterFunc = base::Value (*)();
20 
21 struct OncValueSignature;
22 
23 struct OncFieldSignature {
24   const char* onc_field_name;
25   const OncValueSignature* value_signature;
26   // If this is non-null, it will be called if the field doesn't have a value
27   // after shill->onc translation and the returned value will be assigned to the
28   // field.
29   DefaultValueSetterFunc default_value_setter = nullptr;
30 };
31 
COMPONENT_EXPORT(CHROMEOS_NETWORK)32 struct COMPONENT_EXPORT(CHROMEOS_NETWORK) OncValueSignature {
33   base::Value::Type onc_type;
34   const OncFieldSignature* fields;
35   const OncValueSignature* onc_array_entry_signature;
36   const OncValueSignature* base_signature;
37 };
38 
39 COMPONENT_EXPORT(CHROMEOS_NETWORK)
40 const OncFieldSignature* GetFieldSignature(const OncValueSignature& signature,
41                                            const std::string& onc_field_name);
42 
43 COMPONENT_EXPORT(CHROMEOS_NETWORK)
44 bool FieldIsCredential(const OncValueSignature& signature,
45                        const std::string& onc_field_name);
46 
47 COMPONENT_EXPORT(CHROMEOS_NETWORK)
48 extern const OncValueSignature kRecommendedSignature;
49 COMPONENT_EXPORT(CHROMEOS_NETWORK) extern const OncValueSignature kEAPSignature;
50 COMPONENT_EXPORT(CHROMEOS_NETWORK)
51 extern const OncValueSignature kIssuerSubjectPatternSignature;
52 COMPONENT_EXPORT(CHROMEOS_NETWORK)
53 extern const OncValueSignature kCertificatePatternSignature;
54 COMPONENT_EXPORT(CHROMEOS_NETWORK)
55 extern const OncValueSignature kIPsecSignature;
56 COMPONENT_EXPORT(CHROMEOS_NETWORK)
57 extern const OncValueSignature kL2TPSignature;
58 COMPONENT_EXPORT(CHROMEOS_NETWORK)
59 extern const OncValueSignature kXAUTHSignature;
60 COMPONENT_EXPORT(CHROMEOS_NETWORK)
61 extern const OncValueSignature kOpenVPNSignature;
62 COMPONENT_EXPORT(CHROMEOS_NETWORK)
63 extern const OncValueSignature kThirdPartyVPNSignature;
64 COMPONENT_EXPORT(CHROMEOS_NETWORK)
65 extern const OncValueSignature kARCVPNSignature;
66 COMPONENT_EXPORT(CHROMEOS_NETWORK)
67 extern const OncValueSignature kVerifyX509Signature;
68 COMPONENT_EXPORT(CHROMEOS_NETWORK) extern const OncValueSignature kVPNSignature;
69 COMPONENT_EXPORT(CHROMEOS_NETWORK)
70 extern const OncValueSignature kEthernetSignature;
71 COMPONENT_EXPORT(CHROMEOS_NETWORK)
72 extern const OncValueSignature kTetherSignature;
73 COMPONENT_EXPORT(CHROMEOS_NETWORK)
74 extern const OncValueSignature kTetherWithStateSignature;
75 COMPONENT_EXPORT(CHROMEOS_NETWORK)
76 extern const OncValueSignature kIPConfigSignature;
77 COMPONENT_EXPORT(CHROMEOS_NETWORK)
78 extern const OncValueSignature kSavedIPConfigSignature;
79 COMPONENT_EXPORT(CHROMEOS_NETWORK)
80 extern const OncValueSignature kStaticIPConfigSignature;
81 COMPONENT_EXPORT(CHROMEOS_NETWORK)
82 extern const OncValueSignature kProxyLocationSignature;
83 COMPONENT_EXPORT(CHROMEOS_NETWORK)
84 extern const OncValueSignature kProxyManualSignature;
85 COMPONENT_EXPORT(CHROMEOS_NETWORK)
86 extern const OncValueSignature kProxySettingsSignature;
87 COMPONENT_EXPORT(CHROMEOS_NETWORK)
88 extern const OncValueSignature kWiFiSignature;
89 COMPONENT_EXPORT(CHROMEOS_NETWORK)
90 extern const OncValueSignature kCertificateSignature;
91 COMPONENT_EXPORT(CHROMEOS_NETWORK)
92 extern const OncValueSignature kScopeSignature;
93 COMPONENT_EXPORT(CHROMEOS_NETWORK)
94 extern const OncValueSignature kNetworkConfigurationSignature;
95 COMPONENT_EXPORT(CHROMEOS_NETWORK)
96 extern const OncValueSignature kGlobalNetworkConfigurationSignature;
97 COMPONENT_EXPORT(CHROMEOS_NETWORK)
98 extern const OncValueSignature kCertificateListSignature;
99 COMPONENT_EXPORT(CHROMEOS_NETWORK)
100 extern const OncValueSignature kNetworkConfigurationListSignature;
101 COMPONENT_EXPORT(CHROMEOS_NETWORK)
102 extern const OncValueSignature kToplevelConfigurationSignature;
103 COMPONENT_EXPORT(CHROMEOS_NETWORK)
104 extern const OncValueSignature kEAPSubjectAlternativeNameMatchListSignature;
105 COMPONENT_EXPORT(CHROMEOS_NETWORK)
106 extern const OncValueSignature kEAPSubjectAlternativeNameMatchSignature;
107 
108 // Derived "ONC with State" signatures.
109 COMPONENT_EXPORT(CHROMEOS_NETWORK)
110 extern const OncValueSignature kNetworkWithStateSignature;
111 COMPONENT_EXPORT(CHROMEOS_NETWORK)
112 extern const OncValueSignature kWiFiWithStateSignature;
113 COMPONENT_EXPORT(CHROMEOS_NETWORK)
114 extern const OncValueSignature kCellularSignature;
115 COMPONENT_EXPORT(CHROMEOS_NETWORK)
116 extern const OncValueSignature kCellularWithStateSignature;
117 COMPONENT_EXPORT(CHROMEOS_NETWORK)
118 extern const OncValueSignature kCellularPaymentPortalSignature;
119 COMPONENT_EXPORT(CHROMEOS_NETWORK)
120 extern const OncValueSignature kCellularProviderSignature;
121 COMPONENT_EXPORT(CHROMEOS_NETWORK)
122 extern const OncValueSignature kCellularApnSignature;
123 COMPONENT_EXPORT(CHROMEOS_NETWORK)
124 extern const OncValueSignature kCellularFoundNetworkSignature;
125 COMPONENT_EXPORT(CHROMEOS_NETWORK)
126 extern const OncValueSignature kSIMLockStatusSignature;
127 
128 }  // namespace onc
129 }  // namespace chromeos
130 
131 #endif  // CHROMEOS_NETWORK_ONC_ONC_SIGNATURE_H_
132