Home | History | Annotate | Download | only in onc
      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 
     10 #include "chromeos/network/onc/onc_signature.h"
     11 
     12 namespace chromeos {
     13 namespace onc {
     14 
     15 struct FieldTranslationEntry {
     16   const char* onc_field_name;
     17   const char* shill_property_name;
     18 };
     19 
     20 struct OncValueTranslationEntry {
     21   const OncValueSignature* onc_signature;
     22   const FieldTranslationEntry* field_translation_table;
     23 };
     24 
     25 struct StringTranslationEntry {
     26   const char* onc_value;
     27   const char* shill_value;
     28 };
     29 
     30 // These tables contain the mapping from ONC strings to Shill strings.
     31 // These are NULL-terminated arrays.
     32 extern const StringTranslationEntry kNetworkTypeTable[];
     33 extern const StringTranslationEntry kVPNTypeTable[];
     34 extern const StringTranslationEntry kWiFiSecurityTable[];
     35 extern const StringTranslationEntry kEAPOuterTable[];
     36 extern const StringTranslationEntry kEAP_PEAP_InnerTable[];
     37 extern const StringTranslationEntry kEAP_TTLS_InnerTable[];
     38 
     39 const FieldTranslationEntry* GetFieldTranslationTable(
     40     const OncValueSignature& onc_signature);
     41 
     42 bool GetShillPropertyName(const std::string& onc_field_name,
     43                           const FieldTranslationEntry table[],
     44                           std::string* shill_property_name);
     45 
     46 // Translate individual strings to Shill using the above tables.
     47 bool TranslateStringToShill(const StringTranslationEntry table[],
     48                             const std::string& onc_value,
     49                             std::string* shill_value);
     50 
     51 // Translate individual strings to ONC using the above tables.
     52 bool TranslateStringToONC(const StringTranslationEntry table[],
     53                           const std::string& shill_value,
     54                           std::string* onc_value);
     55 
     56 }  // namespace onc
     57 }  // namespace chromeos
     58 
     59 #endif  // CHROMEOS_NETWORK_ONC_ONC_TRANSLATION_TABLES_H_
     60