Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 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 SHILL_TECHNOLOGY_ |
| 6 | #define SHILL_TECHNOLOGY_ |
| 7 | |
| 8 | #include <string> |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 9 | #include <vector> |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 10 | |
| 11 | namespace shill { |
| 12 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 13 | class Error; |
| 14 | |
Ben Chan | c12cf66 | 2012-04-05 14:47:18 -0700 | [diff] [blame] | 15 | // A class that provides functions for converting between technology names |
| 16 | // and identifiers. |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 17 | class Technology { |
| 18 | public: |
| 19 | enum Identifier { |
| 20 | kEthernet, |
Paul Stewart | 44dba7b | 2013-04-16 09:43:42 -0700 | [diff] [blame] | 21 | kEthernetEap, |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 22 | kWifi, |
Paul Stewart | 2001a42 | 2011-12-15 10:20:09 -0800 | [diff] [blame] | 23 | kWiFiMonitor, |
Ben Chan | 46af127 | 2012-05-01 10:34:00 -0700 | [diff] [blame] | 24 | kWiMax, |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 25 | kCellular, |
Darin Petkov | 33af05c | 2012-02-28 10:10:30 +0100 | [diff] [blame] | 26 | kVPN, |
Paul Stewart | cba0f7f | 2012-02-29 16:33:05 -0800 | [diff] [blame] | 27 | kTunnel, |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 28 | kBlacklisted, |
Paul Stewart | e81eb70 | 2012-04-11 15:04:53 -0700 | [diff] [blame] | 29 | kLoopback, |
Paul Stewart | 050cfc0 | 2012-07-06 20:38:54 -0700 | [diff] [blame] | 30 | kCDCEthernet, // Only for internal use in DeviceInfo. |
mukesh agrawal | 93a29ed | 2012-04-17 16:13:01 -0700 | [diff] [blame] | 31 | kVirtioEthernet, // Only for internal use in DeviceInfo. |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 32 | kPPP, |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 33 | kUnknown, |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
Ben Chan | c12cf66 | 2012-04-05 14:47:18 -0700 | [diff] [blame] | 36 | // Returns the technology identifier for a technology name in |name|, |
| 37 | // or Technology::kUnknown if the technology name is unknown. |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 38 | static Identifier IdentifierFromName(const std::string &name); |
Ben Chan | c12cf66 | 2012-04-05 14:47:18 -0700 | [diff] [blame] | 39 | |
| 40 | // Returns the technology name for a technology identifier in |id|, |
| 41 | // or Technology::kUnknownName ("Unknown") if the technology identifier |
| 42 | // is unknown. |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 43 | static std::string NameFromIdentifier(Identifier id); |
Ben Chan | c12cf66 | 2012-04-05 14:47:18 -0700 | [diff] [blame] | 44 | |
| 45 | // Returns the technology identifier for a storage group identifier in |
| 46 | // |group|, which should have the format of <technology name>_<suffix>, |
| 47 | // or Technology::kUnknown if |group| is not prefixed with a known |
| 48 | // technology name. |
Paul Stewart | 1b25314 | 2012-01-26 14:05:52 -0800 | [diff] [blame] | 49 | static Identifier IdentifierFromStorageGroup(const std::string &group); |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 50 | |
Ben Chan | c12cf66 | 2012-04-05 14:47:18 -0700 | [diff] [blame] | 51 | // Converts the comma-separated list of technology names (with no whitespace |
| 52 | // around commas) in |technologies_string| into a vector of technology |
| 53 | // identifiers output in |technologies_vector|. Returns true if the |
| 54 | // |technologies_string| contains a valid set of technologies with no |
| 55 | // duplicate elements, false otherwise. |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 56 | static bool GetTechnologyVectorFromString( |
| 57 | const std::string &technologies_string, |
| 58 | std::vector<Identifier> *technologies_vector, |
| 59 | Error *error); |
| 60 | |
Ben Chan | 5086b97 | 2013-01-15 21:51:38 -0800 | [diff] [blame] | 61 | // Returns true if |technology| is a primary connectivity technology, i.e. |
| 62 | // Ethernet, Cellular, WiFi, or WiMAX. |
| 63 | static bool IsPrimaryConnectivityTechnology(Identifier technology); |
| 64 | |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 65 | private: |
Paul Stewart | e81eb70 | 2012-04-11 15:04:53 -0700 | [diff] [blame] | 66 | static const char kLoopbackName[]; |
Paul Stewart | cba0f7f | 2012-02-29 16:33:05 -0800 | [diff] [blame] | 67 | static const char kTunnelName[]; |
Paul Stewart | ca876ee | 2012-04-21 08:55:58 -0700 | [diff] [blame] | 68 | static const char kPPPName[]; |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 69 | static const char kUnknownName[]; |
| 70 | }; |
| 71 | |
| 72 | } // namespace shill |
| 73 | |
| 74 | #endif // SHILL_TECHNOLOGY_ |