blob: 67038bc8fb30cad1c565acd1ee3736d9c9398970 [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,
21 kWifi,
Paul Stewart2001a422011-12-15 10:20:09 -080022 kWiFiMonitor,
Paul Stewartfdd16072011-09-16 12:41:35 -070023 kCellular,
Darin Petkov33af05c2012-02-28 10:10:30 +010024 kVPN,
Paul Stewartcba0f7f2012-02-29 16:33:05 -080025 kTunnel,
Paul Stewartfdd16072011-09-16 12:41:35 -070026 kBlacklisted,
Paul Stewarte81eb702012-04-11 15:04:53 -070027 kLoopback,
mukesh agrawal93a29ed2012-04-17 16:13:01 -070028 kVirtioEthernet, // Only for internal use in DeviceInfo.
Paul Stewartca876ee2012-04-21 08:55:58 -070029 kPPP,
Paul Stewartfdd16072011-09-16 12:41:35 -070030 kUnknown,
Paul Stewartfdd16072011-09-16 12:41:35 -070031 };
32
Ben Chanc12cf662012-04-05 14:47:18 -070033 // Returns the technology identifier for a technology name in |name|,
34 // or Technology::kUnknown if the technology name is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070035 static Identifier IdentifierFromName(const std::string &name);
Ben Chanc12cf662012-04-05 14:47:18 -070036
37 // Returns the technology name for a technology identifier in |id|,
38 // or Technology::kUnknownName ("Unknown") if the technology identifier
39 // is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070040 static std::string NameFromIdentifier(Identifier id);
Ben Chanc12cf662012-04-05 14:47:18 -070041
42 // Returns the technology identifier for a storage group identifier in
43 // |group|, which should have the format of <technology name>_<suffix>,
44 // or Technology::kUnknown if |group| is not prefixed with a known
45 // technology name.
Paul Stewart1b253142012-01-26 14:05:52 -080046 static Identifier IdentifierFromStorageGroup(const std::string &group);
Paul Stewartfdd16072011-09-16 12:41:35 -070047
Ben Chanc12cf662012-04-05 14:47:18 -070048 // Converts the comma-separated list of technology names (with no whitespace
49 // around commas) in |technologies_string| into a vector of technology
50 // identifiers output in |technologies_vector|. Returns true if the
51 // |technologies_string| contains a valid set of technologies with no
52 // duplicate elements, false otherwise.
Paul Stewart20088d82012-02-16 06:58:55 -080053 static bool GetTechnologyVectorFromString(
54 const std::string &technologies_string,
55 std::vector<Identifier> *technologies_vector,
56 Error *error);
57
Paul Stewartfdd16072011-09-16 12:41:35 -070058 private:
Paul Stewarte81eb702012-04-11 15:04:53 -070059 static const char kLoopbackName[];
Paul Stewartcba0f7f2012-02-29 16:33:05 -080060 static const char kTunnelName[];
Paul Stewartca876ee2012-04-21 08:55:58 -070061 static const char kPPPName[];
Paul Stewartfdd16072011-09-16 12:41:35 -070062 static const char kUnknownName[];
63};
64
65} // namespace shill
66
67#endif // SHILL_TECHNOLOGY_