1 /* 2 * Copyright 2018, 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 */ 16 17 #pragma once 18 19 #include "command.h" 20 #include "result.h" 21 22 #include <string> 23 #include <unordered_map> 24 #include <unordered_set> 25 #include <vector> 26 27 class WifiCommand : public Command { 28 public: 29 WifiCommand(); 30 virtual ~WifiCommand() = default; 31 32 Result onCommand(const char* command, const char* args) override; 33 private: 34 void readConfig(); 35 Result writeConfig(); 36 Result triggerHostApd(); 37 Result setBlocked(const char* ifName, bool blocked); 38 39 Result onAdd(const std::vector<std::string>& args); 40 Result onBlock(const std::vector<std::string>& args); 41 Result onUnblock(const std::vector<std::string>& args); 42 43 struct AccessPoint { AccessPointAccessPoint44 AccessPoint() : blocked(false) {} 45 std::string ifName; 46 std::string ssid; 47 std::string password; 48 bool blocked; 49 }; 50 51 std::unordered_map<std::string, AccessPoint> mAccessPoints; 52 std::unordered_set<std::string> mUsedInterfaces; 53 int mLowestInterfaceNumber; 54 }; 55 56