1 /* 2 * Copyright (C) 2008 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 #ifndef _CONTROLLER_H 18 #define _CONTROLLER_H 19 20 #include <unistd.h> 21 #include <sys/types.h> 22 23 #include <utils/List.h> 24 25 class PropertyManager; 26 class IControllerHandler; 27 28 #include "PropertyManager.h" 29 30 class Controller { 31 /* 32 * Name of this controller - WIFI/VPN/USBNET/BTNET/BTDUN/LOOP/etc 33 */ 34 char *mName; 35 36 /* 37 * Name of the system ethernet interface which this controller is 38 * bound to. 39 */ 40 char *mBoundInterface; 41 42 protected: 43 PropertyManager *mPropMngr; 44 IControllerHandler *mHandlers; 45 46 public: 47 Controller(const char *name, PropertyManager *propMngr, 48 IControllerHandler *handlers); 49 virtual ~Controller(); 50 51 virtual int start(); 52 virtual int stop(); 53 getName()54 const char *getName() { return mName; } getBoundInterface()55 const char *getBoundInterface() { return mBoundInterface; } 56 57 protected: 58 int loadKernelModule(char *modpath, const char *args); 59 bool isKernelModuleLoaded(const char *modtag); 60 int unloadKernelModule(const char *modtag); 61 int bindInterface(const char *ifname); 62 int unbindInterface(const char *ifname); 63 64 private: 65 void *loadFile(char *filename, unsigned int *_size); 66 }; 67 68 typedef android::List<Controller *> ControllerCollection; 69 #endif 70