summaryrefslogtreecommitdiffstats
path: root/chromeos/network/onc/onc_translation_tables.h
blob: b737542ddc0db878a9349138a24dfe5001890242 (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
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_NETWORK_ONC_ONC_TRANSLATION_TABLES_H_
#define CHROMEOS_NETWORK_ONC_ONC_TRANSLATION_TABLES_H_

#include <string>
#include <vector>

#include "chromeos/chromeos_export.h"
#include "chromeos/network/onc/onc_signature.h"

namespace chromeos {
namespace onc {

struct FieldTranslationEntry {
  const char* onc_field_name;
  const char* shill_property_name;
};

struct StringTranslationEntry {
  const char* onc_value;
  const char* shill_value;
};

// These tables contain the mapping from ONC strings to Shill strings.
// These are NULL-terminated arrays.
CHROMEOS_EXPORT extern const StringTranslationEntry kNetworkTypeTable[];
CHROMEOS_EXPORT extern const StringTranslationEntry kVPNTypeTable[];
CHROMEOS_EXPORT extern const StringTranslationEntry kWiFiSecurityTable[];
CHROMEOS_EXPORT extern const StringTranslationEntry kEAPOuterTable[];
CHROMEOS_EXPORT extern const StringTranslationEntry kEAP_PEAP_InnerTable[];
CHROMEOS_EXPORT extern const StringTranslationEntry kEAP_TTLS_InnerTable[];
CHROMEOS_EXPORT extern const StringTranslationEntry kActivationStateTable[];
CHROMEOS_EXPORT extern const StringTranslationEntry kRoamingStateTable[];

// A separate translation table for cellular properties that are stored in a
// Shill Device instead of a Service. The |shill_property_name| entries
// reference Device properties, not Service properties.
extern const FieldTranslationEntry kCellularDeviceTable[];

const FieldTranslationEntry* GetFieldTranslationTable(
    const OncValueSignature& onc_signature);

// Returns the path at which the translation of an ONC object will be stored in
// a Shill dictionary if its signature is |onc_signature|.
// The default is that values are stored directly in the top level of the Shill
// dictionary.
std::vector<std::string> GetPathToNestedShillDictionary(
    const OncValueSignature& onc_signature);

bool GetShillPropertyName(const std::string& onc_field_name,
                          const FieldTranslationEntry table[],
                          std::string* shill_property_name);

// Translate individual strings to Shill using the above tables.
CHROMEOS_EXPORT bool TranslateStringToShill(
    const StringTranslationEntry table[],
    const std::string& onc_value,
    std::string* shill_value);

// Translate individual strings to ONC using the above tables.
CHROMEOS_EXPORT bool TranslateStringToONC(const StringTranslationEntry table[],
                                          const std::string& shill_value,
                                          std::string* onc_value);

}  // namespace onc
}  // namespace chromeos

#endif  // CHROMEOS_NETWORK_ONC_ONC_TRANSLATION_TABLES_H_