1d18304287dbabc7835be771400b85d4ae8b63de6San Mehat/* 2d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * Copyright (C) 2008 The Android Open Source Project 3d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * 4d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * Licensed under the Apache License, Version 2.0 (the "License"); 5d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * you may not use this file except in compliance with the License. 6d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * You may obtain a copy of the License at 7d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * 8d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * http://www.apache.org/licenses/LICENSE-2.0 9d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * 10d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * Unless required by applicable law or agreed to in writing, software 11d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * distributed under the License is distributed on an "AS IS" BASIS, 12d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * See the License for the specific language governing permissions and 14d18304287dbabc7835be771400b85d4ae8b63de6San Mehat * limitations under the License. 15d18304287dbabc7835be771400b85d4ae8b63de6San Mehat */ 16d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 17d18304287dbabc7835be771400b85d4ae8b63de6San Mehat#ifndef _COMMANDLISTENER_H__ 18d18304287dbabc7835be771400b85d4ae8b63de6San Mehat#define _COMMANDLISTENER_H__ 19d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 20d18304287dbabc7835be771400b85d4ae8b63de6San Mehat#include <sysutils/FrameworkListener.h> 219ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat 22d18304287dbabc7835be771400b85d4ae8b63de6San Mehat#include "NetdCommand.h" 239d10b341a0ba46f108cb96e46691197d778cbc06San Mehat#include "TetherController.h" 249ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat#include "NatController.h" 25d5573d34c8fac49e16b20cf144486125bf940086San Mehat#include "PppController.h" 265af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt#include "SoftapController.h" 274a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall#include "BandwidthController.h" 280031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#include "IdletimerController.h" 292eab1f762badb7ba46b95716e62ea4548a979903Dmitry Shmidt#include "InterfaceController.h" 3089c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk#include "ResolverController.h" 31fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt#include "SecondaryTableController.h" 32d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey#include "FirewallController.h" 33d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 34d18304287dbabc7835be771400b85d4ae8b63de6San Mehatclass CommandListener : public FrameworkListener { 359d10b341a0ba46f108cb96e46691197d778cbc06San Mehat static TetherController *sTetherCtrl; 369ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat static NatController *sNatCtrl; 37d5573d34c8fac49e16b20cf144486125bf940086San Mehat static PppController *sPppCtrl; 385af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt static SoftapController *sSoftapCtrl; 394a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall static BandwidthController *sBandwidthCtrl; 400031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall static IdletimerController *sIdletimerCtrl; 412eab1f762badb7ba46b95716e62ea4548a979903Dmitry Shmidt static InterfaceController *sInterfaceCtrl; 4289c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk static ResolverController *sResolverCtrl; 43fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt static SecondaryTableController *sSecondaryTableCtrl; 44d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey static FirewallController *sFirewallCtrl; 459d10b341a0ba46f108cb96e46691197d778cbc06San Mehat 46d18304287dbabc7835be771400b85d4ae8b63de6San Mehatpublic: 47d18304287dbabc7835be771400b85d4ae8b63de6San Mehat CommandListener(); 48d18304287dbabc7835be771400b85d4ae8b63de6San Mehat virtual ~CommandListener() {} 49d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 50d18304287dbabc7835be771400b85d4ae8b63de6San Mehatprivate: 51d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 52c1b3870147acd0dd42e2e767df08b4d64d5d2423repo sync static int writeFile(const char *path, const char *value, int size); 53c1b3870147acd0dd42e2e767df08b4d64d5d2423repo sync 548e46896b4c4be5deaef651a12b17314f63ae9070San Mehat static int readInterfaceCounters(const char *iface, unsigned long *rx, unsigned long *tx); 558e46896b4c4be5deaef651a12b17314f63ae9070San Mehat 565af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt class SoftapCmd : public NetdCommand { 575af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt public: 585af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt SoftapCmd(); 595af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt virtual ~SoftapCmd() {} 605af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt int runCommand(SocketClient *c, int argc, char ** argv); 615af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt }; 625af38c360587ca2eef0badf6137ccf018f8cd4aaDmitry Shmidt 635c1b8af16dbbc20c89aaca2f93e725e12b16d055San Mehat class InterfaceCmd : public NetdCommand { 64d18304287dbabc7835be771400b85d4ae8b63de6San Mehat public: 655c1b8af16dbbc20c89aaca2f93e725e12b16d055San Mehat InterfaceCmd(); 665c1b8af16dbbc20c89aaca2f93e725e12b16d055San Mehat virtual ~InterfaceCmd() {} 67d18304287dbabc7835be771400b85d4ae8b63de6San Mehat int runCommand(SocketClient *c, int argc, char ** argv); 68d18304287dbabc7835be771400b85d4ae8b63de6San Mehat }; 69d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 70d18304287dbabc7835be771400b85d4ae8b63de6San Mehat class IpFwdCmd : public NetdCommand { 71d18304287dbabc7835be771400b85d4ae8b63de6San Mehat public: 72d18304287dbabc7835be771400b85d4ae8b63de6San Mehat IpFwdCmd(); 73d18304287dbabc7835be771400b85d4ae8b63de6San Mehat virtual ~IpFwdCmd() {} 74d18304287dbabc7835be771400b85d4ae8b63de6San Mehat int runCommand(SocketClient *c, int argc, char ** argv); 75d18304287dbabc7835be771400b85d4ae8b63de6San Mehat }; 76d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 77d18304287dbabc7835be771400b85d4ae8b63de6San Mehat class TetherCmd : public NetdCommand { 78d18304287dbabc7835be771400b85d4ae8b63de6San Mehat public: 79d18304287dbabc7835be771400b85d4ae8b63de6San Mehat TetherCmd(); 80d18304287dbabc7835be771400b85d4ae8b63de6San Mehat virtual ~TetherCmd() {} 81d18304287dbabc7835be771400b85d4ae8b63de6San Mehat int runCommand(SocketClient *c, int argc, char ** argv); 82d18304287dbabc7835be771400b85d4ae8b63de6San Mehat }; 83d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 84d18304287dbabc7835be771400b85d4ae8b63de6San Mehat class NatCmd : public NetdCommand { 85d18304287dbabc7835be771400b85d4ae8b63de6San Mehat public: 86d18304287dbabc7835be771400b85d4ae8b63de6San Mehat NatCmd(); 87d18304287dbabc7835be771400b85d4ae8b63de6San Mehat virtual ~NatCmd() {} 88d18304287dbabc7835be771400b85d4ae8b63de6San Mehat int runCommand(SocketClient *c, int argc, char ** argv); 89d18304287dbabc7835be771400b85d4ae8b63de6San Mehat }; 90d5573d34c8fac49e16b20cf144486125bf940086San Mehat 91d5573d34c8fac49e16b20cf144486125bf940086San Mehat class ListTtysCmd : public NetdCommand { 92d5573d34c8fac49e16b20cf144486125bf940086San Mehat public: 93d5573d34c8fac49e16b20cf144486125bf940086San Mehat ListTtysCmd(); 94d5573d34c8fac49e16b20cf144486125bf940086San Mehat virtual ~ListTtysCmd() {} 95d5573d34c8fac49e16b20cf144486125bf940086San Mehat int runCommand(SocketClient *c, int argc, char ** argv); 96d5573d34c8fac49e16b20cf144486125bf940086San Mehat }; 97d5573d34c8fac49e16b20cf144486125bf940086San Mehat 98d5573d34c8fac49e16b20cf144486125bf940086San Mehat class PppdCmd : public NetdCommand { 99d5573d34c8fac49e16b20cf144486125bf940086San Mehat public: 100d5573d34c8fac49e16b20cf144486125bf940086San Mehat PppdCmd(); 101d5573d34c8fac49e16b20cf144486125bf940086San Mehat virtual ~PppdCmd() {} 102d5573d34c8fac49e16b20cf144486125bf940086San Mehat int runCommand(SocketClient *c, int argc, char ** argv); 103d5573d34c8fac49e16b20cf144486125bf940086San Mehat }; 1041bdac9e98c1ef37ba568b6cf23bfbc09cfe6bf15San Mehat 1054a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall class BandwidthControlCmd : public NetdCommand { 1064a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall public: 1074a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall BandwidthControlCmd(); 1084a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall virtual ~BandwidthControlCmd() {} 1094a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall int runCommand(SocketClient *c, int argc, char ** argv); 110db7da58e8d2aa021060098057f944ef754be06e3JP Abgrall protected: 111db7da58e8d2aa021060098057f944ef754be06e3JP Abgrall void sendGenericOkFail(SocketClient *cli, int cond); 112db7da58e8d2aa021060098057f944ef754be06e3JP Abgrall void sendGenericOpFailed(SocketClient *cli, const char *errMsg); 113db7da58e8d2aa021060098057f944ef754be06e3JP Abgrall void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg); 1144a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11JP Abgrall }; 1153c8cc74f81d0f81204bd827076889bb51143dff8Robert Greenwalt 1160031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall class IdletimerControlCmd : public NetdCommand { 1170031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall public: 1180031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall IdletimerControlCmd(); 1190031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall virtual ~IdletimerControlCmd() {} 1200031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int runCommand(SocketClient *c, int argc, char ** argv); 1210031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall }; 1220031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 12389c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk class ResolverCmd : public NetdCommand { 12489c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk public: 12589c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk ResolverCmd(); 12689c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk virtual ~ResolverCmd() {} 12789c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk int runCommand(SocketClient *c, int argc, char ** argv); 12889c1e975f0c03997808d35c7be10b244c5309f9fMattias Falk }; 129d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey 130d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey class FirewallCmd: public NetdCommand { 131d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey public: 132d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey FirewallCmd(); 133d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey virtual ~FirewallCmd() {} 134d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey int runCommand(SocketClient *c, int argc, char ** argv); 135d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey protected: 136d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey int sendGenericOkFail(SocketClient *cli, int cond); 137d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey static FirewallRule parseRule(const char* arg); 138d8c64026aaae5a9987151b719bd840ec7d68747aJeff Sharkey }; 139d18304287dbabc7835be771400b85d4ae8b63de6San Mehat}; 140d18304287dbabc7835be771400b85d4ae8b63de6San Mehat 141d18304287dbabc7835be771400b85d4ae8b63de6San Mehat#endif 142