onc_translation_tables.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
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 "chromeos/chromeos_export.h" 12#include "chromeos/network/onc/onc_signature.h" 13 14namespace chromeos { 15namespace onc { 16 17struct FieldTranslationEntry { 18 const char* onc_field_name; 19 const char* shill_property_name; 20}; 21 22struct 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. 29CHROMEOS_EXPORT extern const StringTranslationEntry kNetworkTypeTable[]; 30CHROMEOS_EXPORT extern const StringTranslationEntry kVPNTypeTable[]; 31CHROMEOS_EXPORT extern const StringTranslationEntry kWiFiSecurityTable[]; 32CHROMEOS_EXPORT extern const StringTranslationEntry kEAPOuterTable[]; 33CHROMEOS_EXPORT extern const StringTranslationEntry kEAP_PEAP_InnerTable[]; 34CHROMEOS_EXPORT extern const StringTranslationEntry kEAP_TTLS_InnerTable[]; 35 36// A separate translation table for cellular properties that are stored in a 37// Shill Device instead of a Service. The |shill_property_name| entries 38// reference Device properties, not Service properties. 39extern const FieldTranslationEntry kCellularDeviceTable[]; 40 41const FieldTranslationEntry* GetFieldTranslationTable( 42 const OncValueSignature& onc_signature); 43 44std::vector<std::string> GetPathToNestedShillDictionary( 45 const OncValueSignature& onc_signature); 46 47bool GetShillPropertyName(const std::string& onc_field_name, 48 const FieldTranslationEntry table[], 49 std::string* shill_property_name); 50 51// Translate individual strings to Shill using the above tables. 52CHROMEOS_EXPORT bool TranslateStringToShill( 53 const StringTranslationEntry table[], 54 const std::string& onc_value, 55 std::string* shill_value); 56 57// Translate individual strings to ONC using the above tables. 58CHROMEOS_EXPORT bool TranslateStringToONC(const StringTranslationEntry table[], 59 const std::string& shill_value, 60 std::string* onc_value); 61 62} // namespace onc 63} // namespace chromeos 64 65#endif // CHROMEOS_NETWORK_ONC_ONC_TRANSLATION_TABLES_H_ 66