blob: d6f2d9f69853987ce2bdaa9636618a3e27debadc [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
Ben Chanc45688b2014-07-02 23:50:45 -07005#ifndef SHILL_TECHNOLOGY_H_
6#define SHILL_TECHNOLOGY_H_
Paul Stewartfdd16072011-09-16 12:41:35 -07007
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,
Garret Kelly2dc218e2015-01-30 11:16:34 -050033 kPPPoE,
Paul Stewartfdd16072011-09-16 12:41:35 -070034 kUnknown,
Paul Stewartfdd16072011-09-16 12:41:35 -070035 };
36
Ben Chanc12cf662012-04-05 14:47:18 -070037 // Returns the technology identifier for a technology name in |name|,
38 // or Technology::kUnknown if the technology name is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070039 static Identifier IdentifierFromName(const std::string &name);
Ben Chanc12cf662012-04-05 14:47:18 -070040
41 // Returns the technology name for a technology identifier in |id|,
42 // or Technology::kUnknownName ("Unknown") if the technology identifier
43 // is unknown.
Paul Stewartfdd16072011-09-16 12:41:35 -070044 static std::string NameFromIdentifier(Identifier id);
Ben Chanc12cf662012-04-05 14:47:18 -070045
46 // Returns the technology identifier for a storage group identifier in
47 // |group|, which should have the format of <technology name>_<suffix>,
48 // or Technology::kUnknown if |group| is not prefixed with a known
49 // technology name.
Paul Stewart1b253142012-01-26 14:05:52 -080050 static Identifier IdentifierFromStorageGroup(const std::string &group);
Paul Stewartfdd16072011-09-16 12:41:35 -070051
Ben Chanc12cf662012-04-05 14:47:18 -070052 // Converts the comma-separated list of technology names (with no whitespace
53 // around commas) in |technologies_string| into a vector of technology
54 // identifiers output in |technologies_vector|. Returns true if the
55 // |technologies_string| contains a valid set of technologies with no
56 // duplicate elements, false otherwise.
Paul Stewart20088d82012-02-16 06:58:55 -080057 static bool GetTechnologyVectorFromString(
58 const std::string &technologies_string,
59 std::vector<Identifier> *technologies_vector,
60 Error *error);
61
Ben Chan5086b972013-01-15 21:51:38 -080062 // Returns true if |technology| is a primary connectivity technology, i.e.
Garret Kellyaab63492015-02-19 22:52:52 -050063 // Ethernet, Cellular, WiFi, WiMAX, or PPPoE.
Ben Chan5086b972013-01-15 21:51:38 -080064 static bool IsPrimaryConnectivityTechnology(Identifier technology);
65
Paul Stewartfdd16072011-09-16 12:41:35 -070066 private:
Paul Stewarte81eb702012-04-11 15:04:53 -070067 static const char kLoopbackName[];
Paul Stewartcba0f7f2012-02-29 16:33:05 -080068 static const char kTunnelName[];
Paul Stewartca876ee2012-04-21 08:55:58 -070069 static const char kPPPName[];
Garret Kelly2dc218e2015-01-30 11:16:34 -050070 static const char kPPPoEName[];
Paul Stewartfdd16072011-09-16 12:41:35 -070071 static const char kUnknownName[];
72};
73
74} // namespace shill
75
Ben Chanc45688b2014-07-02 23:50:45 -070076#endif // SHILL_TECHNOLOGY_H_