blob: 4801a256255bcdf673d3e2856d65bee4c426d593 [file] [log] [blame]
Paul Stewartfa11e282013-12-02 22:04:25 -08001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "shill/tethering.h"
6
Ben Chancc67c522014-09-03 07:19:18 -07007#include <base/macros.h>
8
Paul Stewartfa11e282013-12-02 22:04:25 -08009using std::set;
10using std::vector;
11
12namespace shill {
13
14// static
Ben Chancc67c522014-09-03 07:19:18 -070015const char Tethering::kAndroidVendorEncapsulatedOptions[] = "ANDROID_METERED";
16const uint8_t Tethering::kAndroidBSSIDPrefix[] = {0x02, 0x1a, 0x11};
Paul Stewartfa11e282013-12-02 22:04:25 -080017const uint32_t Tethering::kIosOui = 0x0017f2;
18const uint8_t Tethering::kLocallyAdministratedMACBit = 0x02;
19
20// static
Paul Stewart1a212a62015-06-16 13:13:10 -070021bool Tethering::IsAndroidBSSID(const vector<uint8_t>& bssid) {
Paul Stewartfa11e282013-12-02 22:04:25 -080022 vector<uint8_t> truncated_bssid = bssid;
23 truncated_bssid.resize(arraysize(kAndroidBSSIDPrefix));
24 return truncated_bssid == vector<uint8_t>(
25 kAndroidBSSIDPrefix,
26 kAndroidBSSIDPrefix + arraysize(kAndroidBSSIDPrefix));
27}
28
29// static
Paul Stewart1a212a62015-06-16 13:13:10 -070030bool Tethering::IsLocallyAdministeredBSSID(const vector<uint8_t>& bssid) {
Paul Stewartfa11e282013-12-02 22:04:25 -080031 return bssid.size() > 0 && (bssid[0] & kLocallyAdministratedMACBit);
32}
33
34// static
Paul Stewart1a212a62015-06-16 13:13:10 -070035bool Tethering::HasIosOui(const set<uint32_t>& oui_set) {
Paul Stewartfa11e282013-12-02 22:04:25 -080036 return oui_set.find(kIosOui) != oui_set.end();
37}
38
39} // namespace shill