blob: 00970c71602d1bad14e8243e30a5c085a2d70408 [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
21bool Tethering::IsAndroidBSSID(const vector<uint8_t> &bssid) {
22 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
30bool Tethering::IsLocallyAdministeredBSSID(const vector<uint8_t> &bssid) {
31 return bssid.size() > 0 && (bssid[0] & kLocallyAdministratedMACBit);
32}
33
34// static
35bool Tethering::HasIosOui(const set<uint32_t> &oui_set) {
36 return oui_set.find(kIosOui) != oui_set.end();
37}
38
39} // namespace shill