blob: 57a5d2b3d27a95fcf5ae9d534c3b2bd235833ca5 [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,
Paul Stewart050cfc02012-07-06 20:38:54 -070029 kCDCEthernet, // Only for internal use in DeviceInfo.
mukesh agrawal93a29ed2012-04-17 16:13:01 -070030 kVirtioEthernet, // Only for internal use in DeviceInfo.
Paul Stewartca876ee2012-04-21 08:55:58 -070031 kPPP,
Paul Stewartfdd16072011-09-16 12:41:35 -070032 kUnknown,
Paul Stewartfdd16072011-09-16 12:41:35 -070033 };
34
Ben Chanc12cf662012-04-05 14:47:18 -070035 // Returns the technology identifier for a technology name in |name|,
36 // or Technology::kUnknown if the technology name is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070037 static Identifier IdentifierFromName(const std::string &name);
Ben Chanc12cf662012-04-05 14:47:18 -070038
39 // Returns the technology name for a technology identifier in |id|,
40 // or Technology::kUnknownName ("Unknown") if the technology identifier
41 // is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070042 static std::string NameFromIdentifier(Identifier id);
Ben Chanc12cf662012-04-05 14:47:18 -070043
44 // Returns the technology identifier for a storage group identifier in
45 // |group|, which should have the format of <technology name>_<suffix>,
46 // or Technology::kUnknown if |group| is not prefixed with a known
47 // technology name.
Paul Stewart1b253142012-01-26 14:05:52 -080048 static Identifier IdentifierFromStorageGroup(const std::string &group);
Paul Stewartfdd16072011-09-16 12:41:35 -070049
Ben Chanc12cf662012-04-05 14:47:18 -070050 // Converts the comma-separated list of technology names (with no whitespace
51 // around commas) in |technologies_string| into a vector of technology
52 // identifiers output in |technologies_vector|. Returns true if the
53 // |technologies_string| contains a valid set of technologies with no
54 // duplicate elements, false otherwise.
Paul Stewart20088d82012-02-16 06:58:55 -080055 static bool GetTechnologyVectorFromString(
56 const std::string &technologies_string,
57 std::vector<Identifier> *technologies_vector,
58 Error *error);
59
Paul Stewartfdd16072011-09-16 12:41:35 -070060 private:
Paul Stewarte81eb702012-04-11 15:04:53 -070061 static const char kLoopbackName[];
Paul Stewartcba0f7f2012-02-29 16:33:05 -080062 static const char kTunnelName[];
Paul Stewartca876ee2012-04-21 08:55:58 -070063 static const char kPPPName[];
Paul Stewartfdd16072011-09-16 12:41:35 -070064 static const char kUnknownName[];
65};
66
67} // namespace shill
68
69#endif // SHILL_TECHNOLOGY_