1 /* 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 */ 16 17 #ifndef _COMMANDLISTENER_H__ 18 #define _COMMANDLISTENER_H__ 19 20 #include <sysutils/FrameworkListener.h> 21 22 #include "NetdCommand.h" 23 #include "TetherController.h" 24 #include "NatController.h" 25 #include "PppController.h" 26 #include "SoftapController.h" 27 #include "BandwidthController.h" 28 #include "IdletimerController.h" 29 #include "InterfaceController.h" 30 #include "ResolverController.h" 31 #include "SecondaryTableController.h" 32 #include "FirewallController.h" 33 #include "ClatdController.h" 34 35 class CommandListener : public FrameworkListener { 36 static TetherController *sTetherCtrl; 37 static NatController *sNatCtrl; 38 static PppController *sPppCtrl; 39 static SoftapController *sSoftapCtrl; 40 static BandwidthController *sBandwidthCtrl; 41 static IdletimerController *sIdletimerCtrl; 42 static InterfaceController *sInterfaceCtrl; 43 static ResolverController *sResolverCtrl; 44 static SecondaryTableController *sSecondaryTableCtrl; 45 static FirewallController *sFirewallCtrl; 46 static ClatdController *sClatdCtrl; 47 48 public: 49 CommandListener(); ~CommandListener()50 virtual ~CommandListener() {} 51 52 private: 53 54 class SoftapCmd : public NetdCommand { 55 public: 56 SoftapCmd(); ~SoftapCmd()57 virtual ~SoftapCmd() {} 58 int runCommand(SocketClient *c, int argc, char ** argv); 59 }; 60 61 class InterfaceCmd : public NetdCommand { 62 public: 63 InterfaceCmd(); ~InterfaceCmd()64 virtual ~InterfaceCmd() {} 65 int runCommand(SocketClient *c, int argc, char ** argv); 66 }; 67 68 class IpFwdCmd : public NetdCommand { 69 public: 70 IpFwdCmd(); ~IpFwdCmd()71 virtual ~IpFwdCmd() {} 72 int runCommand(SocketClient *c, int argc, char ** argv); 73 }; 74 75 class TetherCmd : public NetdCommand { 76 public: 77 TetherCmd(); ~TetherCmd()78 virtual ~TetherCmd() {} 79 int runCommand(SocketClient *c, int argc, char ** argv); 80 }; 81 82 class NatCmd : public NetdCommand { 83 public: 84 NatCmd(); ~NatCmd()85 virtual ~NatCmd() {} 86 int runCommand(SocketClient *c, int argc, char ** argv); 87 }; 88 89 class ListTtysCmd : public NetdCommand { 90 public: 91 ListTtysCmd(); ~ListTtysCmd()92 virtual ~ListTtysCmd() {} 93 int runCommand(SocketClient *c, int argc, char ** argv); 94 }; 95 96 class PppdCmd : public NetdCommand { 97 public: 98 PppdCmd(); ~PppdCmd()99 virtual ~PppdCmd() {} 100 int runCommand(SocketClient *c, int argc, char ** argv); 101 }; 102 103 class BandwidthControlCmd : public NetdCommand { 104 public: 105 BandwidthControlCmd(); ~BandwidthControlCmd()106 virtual ~BandwidthControlCmd() {} 107 int runCommand(SocketClient *c, int argc, char ** argv); 108 protected: 109 void sendGenericOkFail(SocketClient *cli, int cond); 110 void sendGenericOpFailed(SocketClient *cli, const char *errMsg); 111 void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg); 112 }; 113 114 class IdletimerControlCmd : public NetdCommand { 115 public: 116 IdletimerControlCmd(); ~IdletimerControlCmd()117 virtual ~IdletimerControlCmd() {} 118 int runCommand(SocketClient *c, int argc, char ** argv); 119 }; 120 121 class ResolverCmd : public NetdCommand { 122 public: 123 ResolverCmd(); ~ResolverCmd()124 virtual ~ResolverCmd() {} 125 int runCommand(SocketClient *c, int argc, char ** argv); 126 }; 127 128 class FirewallCmd: public NetdCommand { 129 public: 130 FirewallCmd(); ~FirewallCmd()131 virtual ~FirewallCmd() {} 132 int runCommand(SocketClient *c, int argc, char ** argv); 133 protected: 134 int sendGenericOkFail(SocketClient *cli, int cond); 135 static FirewallRule parseRule(const char* arg); 136 }; 137 138 class ClatdCmd : public NetdCommand { 139 public: 140 ClatdCmd(); ~ClatdCmd()141 virtual ~ClatdCmd() {} 142 int runCommand(SocketClient *c, int argc, char ** argv); 143 }; 144 }; 145 146 #endif 147