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 "NetworkController.h"
24 #include "TetherController.h"
25 #include "NatController.h"
26 #include "PppController.h"
27 #include "SoftapController.h"
28 #include "BandwidthController.h"
29 #include "IdletimerController.h"
30 #include "InterfaceController.h"
31 #include "ResolverController.h"
32 #include "SecondaryTableController.h"
33 #include "FirewallController.h"
34 #include "ClatdController.h"
36 class PermissionsController;
37 class RouteController;
39 class CommandListener : public FrameworkListener {
40 static TetherController *sTetherCtrl;
41 static NatController *sNatCtrl;
42 static PppController *sPppCtrl;
43 static SoftapController *sSoftapCtrl;
44 static BandwidthController *sBandwidthCtrl;
45 static IdletimerController *sIdletimerCtrl;
46 static InterfaceController *sInterfaceCtrl;
47 static ResolverController *sResolverCtrl;
48 static SecondaryTableController *sSecondaryTableCtrl;
49 static FirewallController *sFirewallCtrl;
50 static ClatdController *sClatdCtrl;
51 static RouteController* sRouteController;
54 static NetworkController *sNetCtrl;
55 static PermissionsController* sPermissionsController;
58 virtual ~CommandListener() {}
62 class SoftapCmd : public NetdCommand {
65 virtual ~SoftapCmd() {}
66 int runCommand(SocketClient *c, int argc, char ** argv);
69 class InterfaceCmd : public NetdCommand {
72 virtual ~InterfaceCmd() {}
73 int runCommand(SocketClient *c, int argc, char ** argv);
76 class IpFwdCmd : public NetdCommand {
79 virtual ~IpFwdCmd() {}
80 int runCommand(SocketClient *c, int argc, char ** argv);
83 class TetherCmd : public NetdCommand {
86 virtual ~TetherCmd() {}
87 int runCommand(SocketClient *c, int argc, char ** argv);
90 class NatCmd : public NetdCommand {
94 int runCommand(SocketClient *c, int argc, char ** argv);
97 class ListTtysCmd : public NetdCommand {
100 virtual ~ListTtysCmd() {}
101 int runCommand(SocketClient *c, int argc, char ** argv);
104 class PppdCmd : public NetdCommand {
107 virtual ~PppdCmd() {}
108 int runCommand(SocketClient *c, int argc, char ** argv);
111 class BandwidthControlCmd : public NetdCommand {
113 BandwidthControlCmd();
114 virtual ~BandwidthControlCmd() {}
115 int runCommand(SocketClient *c, int argc, char ** argv);
117 void sendGenericOkFail(SocketClient *cli, int cond);
118 void sendGenericOpFailed(SocketClient *cli, const char *errMsg);
119 void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg);
122 class IdletimerControlCmd : public NetdCommand {
124 IdletimerControlCmd();
125 virtual ~IdletimerControlCmd() {}
126 int runCommand(SocketClient *c, int argc, char ** argv);
129 class ResolverCmd : public NetdCommand {
132 virtual ~ResolverCmd() {}
133 int runCommand(SocketClient *c, int argc, char ** argv);
136 class FirewallCmd: public NetdCommand {
139 virtual ~FirewallCmd() {}
140 int runCommand(SocketClient *c, int argc, char ** argv);
142 int sendGenericOkFail(SocketClient *cli, int cond);
143 static FirewallRule parseRule(const char* arg);
146 class ClatdCmd : public NetdCommand {
149 virtual ~ClatdCmd() {}
150 int runCommand(SocketClient *c, int argc, char ** argv);
153 class NetworkCommand : public NetdCommand {
156 virtual ~NetworkCommand() {}
157 int runCommand(SocketClient* client, int argc, char** argv);
159 int syntaxError(SocketClient* cli, const char* message);
160 int paramError(SocketClient* cli, const char* message);
161 int operationError(SocketClient* cli, const char* message);
162 int success(SocketClient* cli);