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_TRANSLATION_TABLES_H_
6 #define CHROMEOS_NETWORK_ONC_ONC_TRANSLATION_TABLES_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/component_export.h"
12 #include "chromeos/network/onc/onc_signature.h"
13 
14 namespace chromeos {
15 namespace onc {
16 
17 struct FieldTranslationEntry {
18   const char* onc_field_name;
19   const char* shill_property_name;
20 };
21 
22 struct StringTranslationEntry {
23   const char* onc_value;
24   const char* shill_value;
25 };
26 
27 // These tables contain the mapping from ONC strings to Shill strings.
28 // These are NULL-terminated arrays.
29 COMPONENT_EXPORT(CHROMEOS_NETWORK)
30 extern const StringTranslationEntry kNetworkTypeTable[];
31 COMPONENT_EXPORT(CHROMEOS_NETWORK)
32 extern const StringTranslationEntry kVPNTypeTable[];
33 COMPONENT_EXPORT(CHROMEOS_NETWORK)
34 extern const StringTranslationEntry kWiFiSecurityTable[];
35 COMPONENT_EXPORT(CHROMEOS_NETWORK)
36 extern const StringTranslationEntry kEAPOuterTable[];
37 COMPONENT_EXPORT(CHROMEOS_NETWORK)
38 extern const StringTranslationEntry kEAP_PEAP_InnerTable[];
39 COMPONENT_EXPORT(CHROMEOS_NETWORK)
40 extern const StringTranslationEntry kEAP_TTLS_InnerTable[];
41 COMPONENT_EXPORT(CHROMEOS_NETWORK)
42 extern const StringTranslationEntry kActivationStateTable[];
43 COMPONENT_EXPORT(CHROMEOS_NETWORK)
44 extern const StringTranslationEntry kNetworkTechnologyTable[];
45 COMPONENT_EXPORT(CHROMEOS_NETWORK)
46 extern const StringTranslationEntry kRoamingStateTable[];
47 COMPONENT_EXPORT(CHROMEOS_NETWORK)
48 extern const StringTranslationEntry kTetheringStateTable[];
49 COMPONENT_EXPORT(CHROMEOS_NETWORK)
50 extern const StringTranslationEntry kOpenVpnCompressionAlgorithmTable[];
51 
52 // A separate translation table for cellular properties that are stored in a
53 // Shill Device instead of a Service. The |shill_property_name| entries
54 // reference Device properties, not Service properties.
55 extern const FieldTranslationEntry kCellularDeviceTable[];
56 
57 const FieldTranslationEntry* GetFieldTranslationTable(
58     const OncValueSignature& onc_signature);
59 
60 // Returns the path at which the translation of an ONC object will be stored in
61 // a Shill dictionary if its signature is |onc_signature|.
62 // The default is that values are stored directly in the top level of the Shill
63 // dictionary.
64 std::vector<std::string> GetPathToNestedShillDictionary(
65     const OncValueSignature& onc_signature);
66 
67 bool GetShillPropertyName(const std::string& onc_field_name,
68                           const FieldTranslationEntry table[],
69                           std::string* shill_property_name);
70 
71 // Translate individual strings to Shill using the above tables.
72 COMPONENT_EXPORT(CHROMEOS_NETWORK)
73 bool TranslateStringToShill(const StringTranslationEntry table[],
74                             const std::string& onc_value,
75                             std::string* shill_value);
76 
77 // Translate individual strings to ONC using the above tables.
78 COMPONENT_EXPORT(CHROMEOS_NETWORK)
79 bool TranslateStringToONC(const StringTranslationEntry table[],
80                           const std::string& shill_value,
81                           std::string* onc_value);
82 
83 }  // namespace onc
84 }  // namespace chromeos
85 
86 #endif  // CHROMEOS_NETWORK_ONC_ONC_TRANSLATION_TABLES_H_
87