Peter Qiu | c0beca5 | 2015-09-03 11:25:46 -0700 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (C) 2013 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 16 | |
| 17 | #include "shill/tethering.h" |
| 18 | |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 19 | #include <base/macros.h> |
| 20 | |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 21 | using std::set; |
| 22 | using std::vector; |
| 23 | |
| 24 | namespace shill { |
| 25 | |
| 26 | // static |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 27 | const char Tethering::kAndroidVendorEncapsulatedOptions[] = "ANDROID_METERED"; |
| 28 | const uint8_t Tethering::kAndroidBSSIDPrefix[] = {0x02, 0x1a, 0x11}; |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 29 | const uint32_t Tethering::kIosOui = 0x0017f2; |
| 30 | const uint8_t Tethering::kLocallyAdministratedMACBit = 0x02; |
| 31 | |
| 32 | // static |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 33 | bool Tethering::IsAndroidBSSID(const vector<uint8_t>& bssid) { |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 34 | vector<uint8_t> truncated_bssid = bssid; |
| 35 | truncated_bssid.resize(arraysize(kAndroidBSSIDPrefix)); |
| 36 | return truncated_bssid == vector<uint8_t>( |
| 37 | kAndroidBSSIDPrefix, |
| 38 | kAndroidBSSIDPrefix + arraysize(kAndroidBSSIDPrefix)); |
| 39 | } |
| 40 | |
| 41 | // static |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 42 | bool Tethering::IsLocallyAdministeredBSSID(const vector<uint8_t>& bssid) { |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 43 | return bssid.size() > 0 && (bssid[0] & kLocallyAdministratedMACBit); |
| 44 | } |
| 45 | |
| 46 | // static |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 47 | bool Tethering::HasIosOui(const set<uint32_t>& oui_set) { |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 48 | return oui_set.find(kIosOui) != oui_set.end(); |
| 49 | } |
| 50 | |
| 51 | } // namespace shill |