San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 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 | */ |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 16 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 17 | #ifndef _CONTROLLER_H |
| 18 | #define _CONTROLLER_H |
| 19 | |
San Mehat | 4876567 | 2009-05-20 15:28:43 -0700 | [diff] [blame] | 20 | #include <unistd.h> |
| 21 | #include <sys/types.h> |
| 22 | |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 23 | #include <utils/List.h> |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 24 | |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 25 | class PropertyManager; |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 26 | class IControllerHandler; |
San Mehat | 4876567 | 2009-05-20 15:28:43 -0700 | [diff] [blame] | 27 | |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 28 | #include "PropertyManager.h" |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 29 | |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 30 | class Controller { |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 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; |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 44 | IControllerHandler *mHandlers; |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 45 | |
| 46 | public: |
San Mehat | 3aff2d1 | 2009-06-15 14:10:44 -0700 | [diff] [blame] | 47 | Controller(const char *name, PropertyManager *propMngr, |
| 48 | IControllerHandler *handlers); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 49 | virtual ~Controller(); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 50 | |
| 51 | virtual int start(); |
| 52 | virtual int stop(); |
| 53 | |
San Mehat | 4876567 | 2009-05-20 15:28:43 -0700 | [diff] [blame] | 54 | const char *getName() { return mName; } |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 55 | const char *getBoundInterface() { return mBoundInterface; } |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 56 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 57 | protected: |
| 58 | int loadKernelModule(char *modpath, const char *args); |
| 59 | bool isKernelModuleLoaded(const char *modtag); |
| 60 | int unloadKernelModule(const char *modtag); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 61 | int bindInterface(const char *ifname); |
| 62 | int unbindInterface(const char *ifname); |
San Mehat | 4876567 | 2009-05-20 15:28:43 -0700 | [diff] [blame] | 63 | |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 64 | private: |
| 65 | void *loadFile(char *filename, unsigned int *_size); |
San Mehat | dc26607 | 2009-05-06 11:16:52 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | typedef android::List<Controller *> ControllerCollection; |
| 69 | #endif |