blob: 9137f9a86513472bd22400424cb604d0c7a6924b [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 Mehat48765672009-05-20 15:28:43 -070026
San Mehat3c5a6f02009-05-22 15:36:13 -070027#include "PropertyManager.h"
28#include "IPropertyProvider.h"
29
30class Controller : public IPropertyProvider {
San Mehatdc266072009-05-06 11:16:52 -070031private:
San Mehat3c5a6f02009-05-22 15:36:13 -070032 /*
33 * Name of this controller - WIFI/VPN/USBNET/BTNET/BTDUN/LOOP/etc
34 */
35 char *mName;
36
37 /*
38 * Name of the system ethernet interface which this controller is
39 * bound to.
40 */
41 char *mBoundInterface;
42
43protected:
44 PropertyManager *mPropMngr;
San Mehatdc266072009-05-06 11:16:52 -070045
46public:
San Mehat3c5a6f02009-05-22 15:36:13 -070047 Controller(const char *name, PropertyManager *propMngr);
48 virtual ~Controller();
San Mehatdc266072009-05-06 11:16:52 -070049
50 virtual int start();
51 virtual int stop();
52
San Mehat48765672009-05-20 15:28:43 -070053 const char *getName() { return mName; }
San Mehat3c5a6f02009-05-22 15:36:13 -070054 const char *getBoundInterface() { return mBoundInterface; }
55
56 /* IPropertyProvider methods */
57 virtual int set(const char *name, const char *value);
58 virtual const char *get(const char *name, char *buffer, size_t maxsize);
San Mehatdc266072009-05-06 11:16:52 -070059
60protected:
61 int loadKernelModule(char *modpath, const char *args);
62 bool isKernelModuleLoaded(const char *modtag);
63 int unloadKernelModule(const char *modtag);
San Mehat3c5a6f02009-05-22 15:36:13 -070064 int bindInterface(const char *ifname);
65 int unbindInterface(const char *ifname);
San Mehat48765672009-05-20 15:28:43 -070066
San Mehatdc266072009-05-06 11:16:52 -070067private:
68 void *loadFile(char *filename, unsigned int *_size);
San Mehatdc266072009-05-06 11:16:52 -070069};
70
71typedef android::List<Controller *> ControllerCollection;
72#endif