• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2012 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef SHILL_TECHNOLOGY_H_
18 #define SHILL_TECHNOLOGY_H_
19 
20 #include <string>
21 #include <vector>
22 
23 namespace shill {
24 
25 class Error;
26 
27 // A class that provides functions for converting between technology names
28 // and identifiers.
29 class Technology {
30  public:
31   enum Identifier {
32     kEthernet,
33     kEthernetEap,
34     kWifi,
35     kWiFiMonitor,
36     kWiMax,
37     kCellular,
38     kVPN,
39     kTunnel,
40     kBlacklisted,
41     kLoopback,
42     kCDCEthernet,  // Only for internal use in DeviceInfo.
43     kVirtioEthernet,  // Only for internal use in DeviceInfo.
44     kNoDeviceSymlink,  // Only for internal use in DeviceInfo.
45     kPPP,
46     kPPPoE,
47     kUnknown,
48   };
49 
50   // Returns the technology identifier for a technology name in |name|,
51   // or Technology::kUnknown if the technology name is unknown.
52   static Identifier IdentifierFromName(const std::string& name);
53 
54   // Returns the technology name for a technology identifier in |id|,
55   // or Technology::kUnknownName ("Unknown") if the technology identifier
56   // is unknown.
57   static std::string NameFromIdentifier(Identifier id);
58 
59   // Returns the technology identifier for a storage group identifier in
60   // |group|, which should have the format of <technology name>_<suffix>,
61   // or Technology::kUnknown if |group| is not prefixed with a known
62   // technology name.
63   static Identifier IdentifierFromStorageGroup(const std::string& group);
64 
65   // Converts the comma-separated list of technology names (with no whitespace
66   // around commas) in |technologies_string| into a vector of technology
67   // identifiers output in |technologies_vector|. Returns true if the
68   // |technologies_string| contains a valid set of technologies with no
69   // duplicate elements, false otherwise.
70   static bool GetTechnologyVectorFromString(
71       const std::string& technologies_string,
72       std::vector<Identifier>* technologies_vector,
73       Error* error);
74 
75   // Returns true if |technology| is a primary connectivity technology, i.e.
76   // Ethernet, Cellular, WiFi, WiMAX, or PPPoE.
77   static bool IsPrimaryConnectivityTechnology(Identifier technology);
78 
79  private:
80   static const char kLoopbackName[];
81   static const char kTunnelName[];
82   static const char kPPPName[];
83   static const char kPPPoEName[];
84   static const char kUnknownName[];
85 };
86 
87 }  // namespace shill
88 
89 #endif  // SHILL_TECHNOLOGY_H_
90