Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 1 | // 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 Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 7 | #include <base/macros.h> |
| 8 | |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 9 | using std::set; |
| 10 | using std::vector; |
| 11 | |
| 12 | namespace shill { |
| 13 | |
| 14 | // static |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 15 | const char Tethering::kAndroidVendorEncapsulatedOptions[] = "ANDROID_METERED"; |
| 16 | const uint8_t Tethering::kAndroidBSSIDPrefix[] = {0x02, 0x1a, 0x11}; |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 17 | const uint32_t Tethering::kIosOui = 0x0017f2; |
| 18 | const uint8_t Tethering::kLocallyAdministratedMACBit = 0x02; |
| 19 | |
| 20 | // static |
| 21 | bool 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 |
| 30 | bool Tethering::IsLocallyAdministeredBSSID(const vector<uint8_t> &bssid) { |
| 31 | return bssid.size() > 0 && (bssid[0] & kLocallyAdministratedMACBit); |
| 32 | } |
| 33 | |
| 34 | // static |
| 35 | bool Tethering::HasIosOui(const set<uint32_t> &oui_set) { |
| 36 | return oui_set.find(kIosOui) != oui_set.end(); |
| 37 | } |
| 38 | |
| 39 | } // namespace shill |