• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "UidMarkMap.h"
35 
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 SecondaryTableController *sSecondaryTableCtrl;
46     static FirewallController *sFirewallCtrl;
47     static ClatdController *sClatdCtrl;
48 
49 public:
50     CommandListener(UidMarkMap *map);
~CommandListener()51     virtual ~CommandListener() {}
52 
53 private:
54 
55     class SoftapCmd : public NetdCommand {
56     public:
57         SoftapCmd();
~SoftapCmd()58         virtual ~SoftapCmd() {}
59         int runCommand(SocketClient *c, int argc, char ** argv);
60     };
61 
62     class InterfaceCmd : public NetdCommand {
63     public:
64         InterfaceCmd();
~InterfaceCmd()65         virtual ~InterfaceCmd() {}
66         int runCommand(SocketClient *c, int argc, char ** argv);
67     };
68 
69     class IpFwdCmd : public NetdCommand {
70     public:
71         IpFwdCmd();
~IpFwdCmd()72         virtual ~IpFwdCmd() {}
73         int runCommand(SocketClient *c, int argc, char ** argv);
74     };
75 
76     class TetherCmd : public NetdCommand {
77     public:
78         TetherCmd();
~TetherCmd()79         virtual ~TetherCmd() {}
80         int runCommand(SocketClient *c, int argc, char ** argv);
81     };
82 
83     class NatCmd : public NetdCommand {
84     public:
85         NatCmd();
~NatCmd()86         virtual ~NatCmd() {}
87         int runCommand(SocketClient *c, int argc, char ** argv);
88     };
89 
90     class ListTtysCmd : public NetdCommand {
91     public:
92         ListTtysCmd();
~ListTtysCmd()93         virtual ~ListTtysCmd() {}
94         int runCommand(SocketClient *c, int argc, char ** argv);
95     };
96 
97     class PppdCmd : public NetdCommand {
98     public:
99         PppdCmd();
~PppdCmd()100         virtual ~PppdCmd() {}
101         int runCommand(SocketClient *c, int argc, char ** argv);
102     };
103 
104     class BandwidthControlCmd : public NetdCommand {
105     public:
106         BandwidthControlCmd();
~BandwidthControlCmd()107         virtual ~BandwidthControlCmd() {}
108         int runCommand(SocketClient *c, int argc, char ** argv);
109     protected:
110         void sendGenericOkFail(SocketClient *cli, int cond);
111         void sendGenericOpFailed(SocketClient *cli, const char *errMsg);
112         void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg);
113     };
114 
115     class IdletimerControlCmd : public NetdCommand {
116     public:
117         IdletimerControlCmd();
~IdletimerControlCmd()118         virtual ~IdletimerControlCmd() {}
119         int runCommand(SocketClient *c, int argc, char ** argv);
120     };
121 
122     class ResolverCmd : public NetdCommand {
123     public:
124         ResolverCmd();
~ResolverCmd()125         virtual ~ResolverCmd() {}
126         int runCommand(SocketClient *c, int argc, char ** argv);
127     };
128 
129     class FirewallCmd: public NetdCommand {
130     public:
131         FirewallCmd();
~FirewallCmd()132         virtual ~FirewallCmd() {}
133         int runCommand(SocketClient *c, int argc, char ** argv);
134     protected:
135         int sendGenericOkFail(SocketClient *cli, int cond);
136         static FirewallRule parseRule(const char* arg);
137     };
138 
139     class ClatdCmd : public NetdCommand {
140     public:
141         ClatdCmd();
~ClatdCmd()142         virtual ~ClatdCmd() {}
143         int runCommand(SocketClient *c, int argc, char ** argv);
144     };
145 };
146 
147 #endif
148