blob: 7c01bf942b15ecddca4752ab2352865767b11e95 [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,
Ben Chan46af1272012-05-01 10:34:00 -070023 kWiMax,
Paul Stewartfdd16072011-09-16 12:41:35 -070024 kCellular,
Darin Petkov33af05c2012-02-28 10:10:30 +010025 kVPN,
Paul Stewartcba0f7f2012-02-29 16:33:05 -080026 kTunnel,
Paul Stewartfdd16072011-09-16 12:41:35 -070027 kBlacklisted,
Paul Stewarte81eb702012-04-11 15:04:53 -070028 kLoopback,
mukesh agrawal93a29ed2012-04-17 16:13:01 -070029 kVirtioEthernet, // Only for internal use in DeviceInfo.
Paul Stewartca876ee2012-04-21 08:55:58 -070030 kPPP,
Paul Stewartfdd16072011-09-16 12:41:35 -070031 kUnknown,
Paul Stewartfdd16072011-09-16 12:41:35 -070032 };
33
Ben Chanc12cf662012-04-05 14:47:18 -070034 // Returns the technology identifier for a technology name in |name|,
35 // or Technology::kUnknown if the technology name is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070036 static Identifier IdentifierFromName(const std::string &name);
Ben Chanc12cf662012-04-05 14:47:18 -070037
38 // Returns the technology name for a technology identifier in |id|,
39 // or Technology::kUnknownName ("Unknown") if the technology identifier
40 // is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070041 static std::string NameFromIdentifier(Identifier id);
Ben Chanc12cf662012-04-05 14:47:18 -070042
43 // Returns the technology identifier for a storage group identifier in
44 // |group|, which should have the format of <technology name>_<suffix>,
45 // or Technology::kUnknown if |group| is not prefixed with a known
46 // technology name.
Paul Stewart1b253142012-01-26 14:05:52 -080047 static Identifier IdentifierFromStorageGroup(const std::string &group);
Paul Stewartfdd16072011-09-16 12:41:35 -070048
Ben Chanc12cf662012-04-05 14:47:18 -070049 // Converts the comma-separated list of technology names (with no whitespace
50 // around commas) in |technologies_string| into a vector of technology
51 // identifiers output in |technologies_vector|. Returns true if the
52 // |technologies_string| contains a valid set of technologies with no
53 // duplicate elements, false otherwise.
Paul Stewart20088d82012-02-16 06:58:55 -080054 static bool GetTechnologyVectorFromString(
55 const std::string &technologies_string,
56 std::vector<Identifier> *technologies_vector,
57 Error *error);
58
Paul Stewartfdd16072011-09-16 12:41:35 -070059 private:
Paul Stewarte81eb702012-04-11 15:04:53 -070060 static const char kLoopbackName[];
Paul Stewartcba0f7f2012-02-29 16:33:05 -080061 static const char kTunnelName[];
Paul Stewartca876ee2012-04-21 08:55:58 -070062 static const char kPPPName[];
Paul Stewartfdd16072011-09-16 12:41:35 -070063 static const char kUnknownName[];
64};
65
66} // namespace shill
67
68#endif // SHILL_TECHNOLOGY_