2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _COMMANDLISTENER_H__
18 #define _COMMANDLISTENER_H__
20 #include <sysutils/FrameworkListener.h>
22 #include "NetdCommand.h"
23 #include "TetherController.h"
24 #include "NatController.h"
25 #include "PppController.h"
26 #include "PanController.h"
27 #include "SoftapController.h"
28 #include "BandwidthController.h"
29 #include "ResolverController.h"
31 class CommandListener : public FrameworkListener {
32 static TetherController *sTetherCtrl;
33 static NatController *sNatCtrl;
34 static PppController *sPppCtrl;
35 static PanController *sPanCtrl;
36 static SoftapController *sSoftapCtrl;
37 static BandwidthController *sBandwidthCtrl;
38 static ResolverController *sResolverCtrl;
42 virtual ~CommandListener() {}
46 static int writeFile(const char *path, const char *value, int size);
48 static int readInterfaceCounters(const char *iface, unsigned long *rx, unsigned long *tx);
50 class SoftapCmd : public NetdCommand {
53 virtual ~SoftapCmd() {}
54 int runCommand(SocketClient *c, int argc, char ** argv);
57 class InterfaceCmd : public NetdCommand {
60 virtual ~InterfaceCmd() {}
61 int runCommand(SocketClient *c, int argc, char ** argv);
64 class IpFwdCmd : public NetdCommand {
67 virtual ~IpFwdCmd() {}
68 int runCommand(SocketClient *c, int argc, char ** argv);
71 class TetherCmd : public NetdCommand {
74 virtual ~TetherCmd() {}
75 int runCommand(SocketClient *c, int argc, char ** argv);
78 class NatCmd : public NetdCommand {
82 int runCommand(SocketClient *c, int argc, char ** argv);
85 class ListTtysCmd : public NetdCommand {
88 virtual ~ListTtysCmd() {}
89 int runCommand(SocketClient *c, int argc, char ** argv);
92 class PppdCmd : public NetdCommand {
96 int runCommand(SocketClient *c, int argc, char ** argv);
99 class PanCmd : public NetdCommand {
103 int runCommand(SocketClient *c, int argc, char ** argv);
106 class BandwidthControlCmd : public NetdCommand {
108 BandwidthControlCmd();
109 virtual ~BandwidthControlCmd() {}
110 int runCommand(SocketClient *c, int argc, char ** argv);
112 void sendGenericOkFail(SocketClient *cli, int cond);
113 void sendGenericOpFailed(SocketClient *cli, const char *errMsg);
114 void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg);
117 class ResolverCmd : public NetdCommand {
120 virtual ~ResolverCmd() {}
121 int runCommand(SocketClient *c, int argc, char ** argv);