blob: e7e17c51f6c02e2b98a9a0c630bb170785789beb [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
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 Mehat3c5a6f02009-05-22 15:36:13 -070016
San Mehatdc266072009-05-06 11:16:52 -070017#ifndef _CONTROLLER_H
18#define _CONTROLLER_H
19
San Mehat48765672009-05-20 15:28:43 -070020#include <unistd.h>
21#include <sys/types.h>
22
San Mehat3c5a6f02009-05-22 15:36:13 -070023#include <utils/List.h>
San Mehatdc266072009-05-06 11:16:52 -070024
San Mehat3c5a6f02009-05-22 15:36:13 -070025class PropertyManager;
San Mehat3aff2d12009-06-15 14:10:44 -070026class IControllerHandler;
San Mehat48765672009-05-20 15:28:43 -070027
San Mehat3c5a6f02009-05-22 15:36:13 -070028#include "PropertyManager.h"
San Mehat3c5a6f02009-05-22 15:36:13 -070029
San Mehatc4a895b2009-06-23 21:10:57 -070030class Controller {
San Mehat3c5a6f02009-05-22 15:36:13 -070031 /*
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
42protected:
43 PropertyManager *mPropMngr;
San Mehat3aff2d12009-06-15 14:10:44 -070044 IControllerHandler *mHandlers;
San Mehatdc266072009-05-06 11:16:52 -070045
46public:
San Mehat3aff2d12009-06-15 14:10:44 -070047 Controller(const char *name, PropertyManager *propMngr,
48 IControllerHandler *handlers);
San Mehat3c5a6f02009-05-22 15:36:13 -070049 virtual ~Controller();
San Mehatdc266072009-05-06 11:16:52 -070050
51 virtual int start();
52 virtual int stop();
53
San Mehat48765672009-05-20 15:28:43 -070054 const char *getName() { return mName; }
San Mehat3c5a6f02009-05-22 15:36:13 -070055 const char *getBoundInterface() { return mBoundInterface; }
San Mehatc4a895b2009-06-23 21:10:57 -070056
San Mehatdc266072009-05-06 11:16:52 -070057protected:
58 int loadKernelModule(char *modpath, const char *args);
59 bool isKernelModuleLoaded(const char *modtag);
60 int unloadKernelModule(const char *modtag);
San Mehat3c5a6f02009-05-22 15:36:13 -070061 int bindInterface(const char *ifname);
62 int unbindInterface(const char *ifname);
San Mehat48765672009-05-20 15:28:43 -070063
San Mehatdc266072009-05-06 11:16:52 -070064private:
65 void *loadFile(char *filename, unsigned int *_size);
San Mehatdc266072009-05-06 11:16:52 -070066};
67
68typedef android::List<Controller *> ControllerCollection;
69#endif