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>
21 #include "utils/RWLock.h"
23 #include "NetdCommand.h"
24 #include "NetdConstants.h"
25 #include "NetworkController.h"
26 #include "TetherController.h"
27 #include "NatController.h"
28 #include "PppController.h"
29 #include "SoftapController.h"
30 #include "BandwidthController.h"
31 #include "IdletimerController.h"
32 #include "InterfaceController.h"
33 #include "ResolverController.h"
34 #include "FirewallController.h"
35 #include "ClatdController.h"
36 #include "StrictController.h"
38 class CommandListener : public FrameworkListener {
41 virtual ~CommandListener() {}
44 void registerLockingCmd(FrameworkCommand *cmd, android::RWLock& lock);
45 void registerLockingCmd(FrameworkCommand *cmd) {
46 registerLockingCmd(cmd, android::net::gBigNetdLock);
49 class SoftapCmd : public NetdCommand {
52 virtual ~SoftapCmd() {}
53 int runCommand(SocketClient *c, int argc, char ** argv);
56 class InterfaceCmd : public NetdCommand {
59 virtual ~InterfaceCmd() {}
60 int runCommand(SocketClient *c, int argc, char ** argv);
63 class IpFwdCmd : public NetdCommand {
66 virtual ~IpFwdCmd() {}
67 int runCommand(SocketClient *c, int argc, char ** argv);
70 class TetherCmd : public NetdCommand {
73 virtual ~TetherCmd() {}
74 int runCommand(SocketClient *c, int argc, char ** argv);
77 class NatCmd : public NetdCommand {
81 int runCommand(SocketClient *c, int argc, char ** argv);
84 class ListTtysCmd : public NetdCommand {
87 virtual ~ListTtysCmd() {}
88 int runCommand(SocketClient *c, int argc, char ** argv);
91 class PppdCmd : public NetdCommand {
95 int runCommand(SocketClient *c, int argc, char ** argv);
98 class BandwidthControlCmd : public NetdCommand {
100 BandwidthControlCmd();
101 virtual ~BandwidthControlCmd() {}
102 int runCommand(SocketClient *c, int argc, char ** argv);
104 void sendGenericOkFail(SocketClient *cli, int cond);
105 void sendGenericOpFailed(SocketClient *cli, const char *errMsg);
106 void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg);
109 class IdletimerControlCmd : public NetdCommand {
111 IdletimerControlCmd();
112 virtual ~IdletimerControlCmd() {}
113 int runCommand(SocketClient *c, int argc, char ** argv);
116 class ResolverCmd : public NetdCommand {
119 virtual ~ResolverCmd() {}
120 int runCommand(SocketClient *c, int argc, char ** argv);
123 bool parseAndExecuteSetNetDns(int netId, int argc, const char** argv);
126 class FirewallCmd: public NetdCommand {
129 virtual ~FirewallCmd() {}
130 int runCommand(SocketClient *c, int argc, char ** argv);
132 int sendGenericOkFail(SocketClient *cli, int cond);
133 static FirewallRule parseRule(const char* arg);
134 static FirewallType parseFirewallType(const char* arg);
135 static ChildChain parseChildChain(const char* arg);
138 class ClatdCmd : public NetdCommand {
141 virtual ~ClatdCmd() {}
142 int runCommand(SocketClient *c, int argc, char ** argv);
145 class StrictCmd : public NetdCommand {
148 virtual ~StrictCmd() {}
149 int runCommand(SocketClient *c, int argc, char ** argv);
151 int sendGenericOkFail(SocketClient *cli, int cond);
152 static StrictPenalty parsePenalty(const char* arg);
155 class NetworkCommand : public NetdCommand {
158 virtual ~NetworkCommand() {}
159 int runCommand(SocketClient* client, int argc, char** argv);
161 int syntaxError(SocketClient* cli, const char* message);
162 int operationError(SocketClient* cli, const char* message, int ret);
163 int success(SocketClient* cli);