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 "PanController.h" 27 #include "SoftapController.h" 28 #include "BandwidthController.h" 29 #include "IdletimerController.h" 30 #include "ResolverController.h" 31 #include "SecondaryTableController.h" 32 33 class CommandListener : public FrameworkListener { 34 static TetherController *sTetherCtrl; 35 static NatController *sNatCtrl; 36 static PppController *sPppCtrl; 37 static PanController *sPanCtrl; 38 static SoftapController *sSoftapCtrl; 39 static BandwidthController *sBandwidthCtrl; 40 static IdletimerController *sIdletimerCtrl; 41 static ResolverController *sResolverCtrl; 42 static SecondaryTableController *sSecondaryTableCtrl; 43 44 public: 45 CommandListener(); 46 virtual ~CommandListener() {} 47 48 private: 49 50 static int writeFile(const char *path, const char *value, int size); 51 52 static int readInterfaceCounters(const char *iface, unsigned long *rx, unsigned long *tx); 53 54 class SoftapCmd : public NetdCommand { 55 public: 56 SoftapCmd(); 57 virtual ~SoftapCmd() {} 58 int runCommand(SocketClient *c, int argc, char ** argv); 59 }; 60 61 class InterfaceCmd : public NetdCommand { 62 public: 63 InterfaceCmd(); 64 virtual ~InterfaceCmd() {} 65 int runCommand(SocketClient *c, int argc, char ** argv); 66 }; 67 68 class IpFwdCmd : public NetdCommand { 69 public: 70 IpFwdCmd(); 71 virtual ~IpFwdCmd() {} 72 int runCommand(SocketClient *c, int argc, char ** argv); 73 }; 74 75 class TetherCmd : public NetdCommand { 76 public: 77 TetherCmd(); 78 virtual ~TetherCmd() {} 79 int runCommand(SocketClient *c, int argc, char ** argv); 80 }; 81 82 class NatCmd : public NetdCommand { 83 public: 84 NatCmd(); 85 virtual ~NatCmd() {} 86 int runCommand(SocketClient *c, int argc, char ** argv); 87 }; 88 89 class ListTtysCmd : public NetdCommand { 90 public: 91 ListTtysCmd(); 92 virtual ~ListTtysCmd() {} 93 int runCommand(SocketClient *c, int argc, char ** argv); 94 }; 95 96 class PppdCmd : public NetdCommand { 97 public: 98 PppdCmd(); 99 virtual ~PppdCmd() {} 100 int runCommand(SocketClient *c, int argc, char ** argv); 101 }; 102 103 class PanCmd : public NetdCommand { 104 public: 105 PanCmd(); 106 virtual ~PanCmd() {} 107 int runCommand(SocketClient *c, int argc, char ** argv); 108 }; 109 110 class BandwidthControlCmd : public NetdCommand { 111 public: 112 BandwidthControlCmd(); 113 virtual ~BandwidthControlCmd() {} 114 int runCommand(SocketClient *c, int argc, char ** argv); 115 protected: 116 void sendGenericOkFail(SocketClient *cli, int cond); 117 void sendGenericOpFailed(SocketClient *cli, const char *errMsg); 118 void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg); 119 }; 120 121 class IdletimerControlCmd : public NetdCommand { 122 public: 123 IdletimerControlCmd(); 124 virtual ~IdletimerControlCmd() {} 125 int runCommand(SocketClient *c, int argc, char ** argv); 126 }; 127 128 class ResolverCmd : public NetdCommand { 129 public: 130 ResolverCmd(); 131 virtual ~ResolverCmd() {} 132 int runCommand(SocketClient *c, int argc, char ** argv); 133 }; 134 }; 135 136 #endif 137