blob: c1e3ddaf80b2f37d9c8fc331d5d424661c1e3dc2 [file] [log] [blame]
Peter Qiuc0beca52015-09-03 11:25:46 -07001//
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 Stewartfa11e282013-12-02 22:04:25 -080016
17#include "shill/tethering.h"
18
Ben Chancc67c522014-09-03 07:19:18 -070019#include <base/macros.h>
20
Paul Stewartfa11e282013-12-02 22:04:25 -080021using std::set;
22using std::vector;
23
24namespace shill {
25
26// static
Ben Chancc67c522014-09-03 07:19:18 -070027const char Tethering::kAndroidVendorEncapsulatedOptions[] = "ANDROID_METERED";
28const uint8_t Tethering::kAndroidBSSIDPrefix[] = {0x02, 0x1a, 0x11};
Paul Stewartfa11e282013-12-02 22:04:25 -080029const uint32_t Tethering::kIosOui = 0x0017f2;
30const uint8_t Tethering::kLocallyAdministratedMACBit = 0x02;
31
32// static
Paul Stewart1a212a62015-06-16 13:13:10 -070033bool Tethering::IsAndroidBSSID(const vector<uint8_t>& bssid) {
Paul Stewartfa11e282013-12-02 22:04:25 -080034 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 Stewart1a212a62015-06-16 13:13:10 -070042bool Tethering::IsLocallyAdministeredBSSID(const vector<uint8_t>& bssid) {
Paul Stewartfa11e282013-12-02 22:04:25 -080043 return bssid.size() > 0 && (bssid[0] & kLocallyAdministratedMACBit);
44}
45
46// static
Paul Stewart1a212a62015-06-16 13:13:10 -070047bool Tethering::HasIosOui(const set<uint32_t>& oui_set) {
Paul Stewartfa11e282013-12-02 22:04:25 -080048 return oui_set.find(kIosOui) != oui_set.end();
49}
50
51} // namespace shill