blob: 821f558c1d1d7531fa9a95676e4f13265f2eb8cb [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 Stewartfdd16072011-09-16 12:41:35 -070029 kUnknown,
Paul Stewartfdd16072011-09-16 12:41:35 -070030 };
31
Ben Chanc12cf662012-04-05 14:47:18 -070032 // Returns the technology identifier for a technology name in |name|,
33 // or Technology::kUnknown if the technology name is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070034 static Identifier IdentifierFromName(const std::string &name);
Ben Chanc12cf662012-04-05 14:47:18 -070035
36 // Returns the technology name for a technology identifier in |id|,
37 // or Technology::kUnknownName ("Unknown") if the technology identifier
38 // is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070039 static std::string NameFromIdentifier(Identifier id);
Ben Chanc12cf662012-04-05 14:47:18 -070040
41 // Returns the technology identifier for a storage group identifier in
42 // |group|, which should have the format of <technology name>_<suffix>,
43 // or Technology::kUnknown if |group| is not prefixed with a known
44 // technology name.
Paul Stewart1b253142012-01-26 14:05:52 -080045 static Identifier IdentifierFromStorageGroup(const std::string &group);
Paul Stewartfdd16072011-09-16 12:41:35 -070046
Ben Chanc12cf662012-04-05 14:47:18 -070047 // Converts the comma-separated list of technology names (with no whitespace
48 // around commas) in |technologies_string| into a vector of technology
49 // identifiers output in |technologies_vector|. Returns true if the
50 // |technologies_string| contains a valid set of technologies with no
51 // duplicate elements, false otherwise.
Paul Stewart20088d82012-02-16 06:58:55 -080052 static bool GetTechnologyVectorFromString(
53 const std::string &technologies_string,
54 std::vector<Identifier> *technologies_vector,
55 Error *error);
56
Paul Stewartfdd16072011-09-16 12:41:35 -070057 private:
Paul Stewarte81eb702012-04-11 15:04:53 -070058 static const char kLoopbackName[];
Paul Stewartcba0f7f2012-02-29 16:33:05 -080059 static const char kTunnelName[];
Paul Stewartfdd16072011-09-16 12:41:35 -070060 static const char kUnknownName[];
61};
62
63} // namespace shill
64
65#endif // SHILL_TECHNOLOGY_