blob: 1863b4cedbe7009375fba3d79ef7797faf58069e [file] [log] [blame]
Paul Stewart20088d82012-02-16 06:58:55 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Paul Stewartfdd16072011-09-16 12:41:35 -07002// 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 Stewart20088d82012-02-16 06:58:55 -08009#include <vector>
Paul Stewartfdd16072011-09-16 12:41:35 -070010
11namespace shill {
12
Paul Stewart20088d82012-02-16 06:58:55 -080013class Error;
14
Ben Chanc12cf662012-04-05 14:47:18 -070015// A class that provides functions for converting between technology names
16// and identifiers.
Paul Stewartfdd16072011-09-16 12:41:35 -070017class Technology {
18 public:
19 enum Identifier {
20 kEthernet,
Paul Stewart44dba7b2013-04-16 09:43:42 -070021 kEthernetEap,
Paul Stewartfdd16072011-09-16 12:41:35 -070022 kWifi,
Paul Stewart2001a422011-12-15 10:20:09 -080023 kWiFiMonitor,
Ben Chan46af1272012-05-01 10:34:00 -070024 kWiMax,
Paul Stewartfdd16072011-09-16 12:41:35 -070025 kCellular,
Darin Petkov33af05c2012-02-28 10:10:30 +010026 kVPN,
Paul Stewartcba0f7f2012-02-29 16:33:05 -080027 kTunnel,
Paul Stewartfdd16072011-09-16 12:41:35 -070028 kBlacklisted,
Paul Stewarte81eb702012-04-11 15:04:53 -070029 kLoopback,
Paul Stewart050cfc02012-07-06 20:38:54 -070030 kCDCEthernet, // Only for internal use in DeviceInfo.
mukesh agrawal93a29ed2012-04-17 16:13:01 -070031 kVirtioEthernet, // Only for internal use in DeviceInfo.
Paul Stewartca876ee2012-04-21 08:55:58 -070032 kPPP,
Paul Stewartfdd16072011-09-16 12:41:35 -070033 kUnknown,
Paul Stewartfdd16072011-09-16 12:41:35 -070034 };
35
Ben Chanc12cf662012-04-05 14:47:18 -070036 // Returns the technology identifier for a technology name in |name|,
37 // or Technology::kUnknown if the technology name is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070038 static Identifier IdentifierFromName(const std::string &name);
Ben Chanc12cf662012-04-05 14:47:18 -070039
40 // Returns the technology name for a technology identifier in |id|,
41 // or Technology::kUnknownName ("Unknown") if the technology identifier
42 // is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070043 static std::string NameFromIdentifier(Identifier id);
Ben Chanc12cf662012-04-05 14:47:18 -070044
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 Stewart1b253142012-01-26 14:05:52 -080049 static Identifier IdentifierFromStorageGroup(const std::string &group);
Paul Stewartfdd16072011-09-16 12:41:35 -070050
Ben Chanc12cf662012-04-05 14:47:18 -070051 // 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 Stewart20088d82012-02-16 06:58:55 -080056 static bool GetTechnologyVectorFromString(
57 const std::string &technologies_string,
58 std::vector<Identifier> *technologies_vector,
59 Error *error);
60
Ben Chan5086b972013-01-15 21:51:38 -080061 // 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 Stewartfdd16072011-09-16 12:41:35 -070065 private:
Paul Stewarte81eb702012-04-11 15:04:53 -070066 static const char kLoopbackName[];
Paul Stewartcba0f7f2012-02-29 16:33:05 -080067 static const char kTunnelName[];
Paul Stewartca876ee2012-04-21 08:55:58 -070068 static const char kPPPName[];
Paul Stewartfdd16072011-09-16 12:41:35 -070069 static const char kUnknownName[];
70};
71
72} // namespace shill
73
74#endif // SHILL_TECHNOLOGY_