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 "FirewallController.h"
33 #include "ClatdController.h"
34 #include "StrictController.h"
36 class CommandListener : public FrameworkListener {
37 static TetherController *sTetherCtrl;
38 static NatController *sNatCtrl;
39 static PppController *sPppCtrl;
40 static SoftapController *sSoftapCtrl;
41 static BandwidthController *sBandwidthCtrl;
42 static IdletimerController *sIdletimerCtrl;
43 static InterfaceController *sInterfaceCtrl;
44 static ResolverController *sResolverCtrl;
45 static FirewallController *sFirewallCtrl;
46 static ClatdController *sClatdCtrl;
47 static StrictController *sStrictCtrl;
50 static NetworkController *sNetCtrl;
53 virtual ~CommandListener() {}
57 class SoftapCmd : public NetdCommand {
60 virtual ~SoftapCmd() {}
61 int runCommand(SocketClient *c, int argc, char ** argv);
64 class InterfaceCmd : public NetdCommand {
67 virtual ~InterfaceCmd() {}
68 int runCommand(SocketClient *c, int argc, char ** argv);
71 class IpFwdCmd : public NetdCommand {
74 virtual ~IpFwdCmd() {}
75 int runCommand(SocketClient *c, int argc, char ** argv);
78 class TetherCmd : public NetdCommand {
81 virtual ~TetherCmd() {}
82 int runCommand(SocketClient *c, int argc, char ** argv);
85 class NatCmd : public NetdCommand {
89 int runCommand(SocketClient *c, int argc, char ** argv);
92 class ListTtysCmd : public NetdCommand {
95 virtual ~ListTtysCmd() {}
96 int runCommand(SocketClient *c, int argc, char ** argv);
99 class PppdCmd : public NetdCommand {
102 virtual ~PppdCmd() {}
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 IdletimerControlCmd : public NetdCommand {
119 IdletimerControlCmd();
120 virtual ~IdletimerControlCmd() {}
121 int runCommand(SocketClient *c, int argc, char ** argv);
124 class ResolverCmd : public NetdCommand {
127 virtual ~ResolverCmd() {}
128 int runCommand(SocketClient *c, int argc, char ** argv);
131 class FirewallCmd: public NetdCommand {
134 virtual ~FirewallCmd() {}
135 int runCommand(SocketClient *c, int argc, char ** argv);
137 int sendGenericOkFail(SocketClient *cli, int cond);
138 static FirewallRule parseRule(const char* arg);
141 class ClatdCmd : public NetdCommand {
144 virtual ~ClatdCmd() {}
145 int runCommand(SocketClient *c, int argc, char ** argv);
148 class StrictCmd : public NetdCommand {
151 virtual ~StrictCmd() {}
152 int runCommand(SocketClient *c, int argc, char ** argv);
154 int sendGenericOkFail(SocketClient *cli, int cond);
155 static StrictPenalty parsePenalty(const char* arg);
158 class NetworkCommand : public NetdCommand {
161 virtual ~NetworkCommand() {}
162 int runCommand(SocketClient* client, int argc, char** argv);
164 int syntaxError(SocketClient* cli, const char* message);
165 int operationError(SocketClient* cli, const char* message, int ret);
166 int success(SocketClient* cli);