OSDN Git Service

am 535b94fa: Merge "Offer to detect non-SSL/TLS network traffic."
[android-x86/system-netd.git] / server / CommandListener.h
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 "NetworkController.h"
24 #include "TetherController.h"
25 #include "NatController.h"
26 #include "PppController.h"
27 #include "SoftapController.h"
28 #include "BandwidthController.h"
29 #include "IdletimerController.h"
30 #include "InterfaceController.h"
31 #include "ResolverController.h"
32 #include "FirewallController.h"
33 #include "ClatdController.h"
34 #include "StrictController.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 FirewallController *sFirewallCtrl;
46     static ClatdController *sClatdCtrl;
47     static StrictController *sStrictCtrl;
48
49 public:
50     static NetworkController *sNetCtrl;
51
52     CommandListener();
53     virtual ~CommandListener() {}
54
55 private:
56
57     class SoftapCmd : public NetdCommand {
58     public:
59         SoftapCmd();
60         virtual ~SoftapCmd() {}
61         int runCommand(SocketClient *c, int argc, char ** argv);
62     };
63
64     class InterfaceCmd : public NetdCommand {
65     public:
66         InterfaceCmd();
67         virtual ~InterfaceCmd() {}
68         int runCommand(SocketClient *c, int argc, char ** argv);
69     };
70
71     class IpFwdCmd : public NetdCommand {
72     public:
73         IpFwdCmd();
74         virtual ~IpFwdCmd() {}
75         int runCommand(SocketClient *c, int argc, char ** argv);
76     };
77
78     class TetherCmd : public NetdCommand {
79     public:
80         TetherCmd();
81         virtual ~TetherCmd() {}
82         int runCommand(SocketClient *c, int argc, char ** argv);
83     };
84
85     class NatCmd : public NetdCommand {
86     public:
87         NatCmd();
88         virtual ~NatCmd() {}
89         int runCommand(SocketClient *c, int argc, char ** argv);
90     };
91
92     class ListTtysCmd : public NetdCommand {
93     public:
94         ListTtysCmd();
95         virtual ~ListTtysCmd() {}
96         int runCommand(SocketClient *c, int argc, char ** argv);
97     };
98
99     class PppdCmd : public NetdCommand {
100     public:
101         PppdCmd();
102         virtual ~PppdCmd() {}
103         int runCommand(SocketClient *c, int argc, char ** argv);
104     };
105
106     class BandwidthControlCmd : public NetdCommand {
107     public:
108         BandwidthControlCmd();
109         virtual ~BandwidthControlCmd() {}
110         int runCommand(SocketClient *c, int argc, char ** argv);
111     protected:
112         void sendGenericOkFail(SocketClient *cli, int cond);
113         void sendGenericOpFailed(SocketClient *cli, const char *errMsg);
114         void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg);
115     };
116
117     class IdletimerControlCmd : public NetdCommand {
118     public:
119         IdletimerControlCmd();
120         virtual ~IdletimerControlCmd() {}
121         int runCommand(SocketClient *c, int argc, char ** argv);
122     };
123
124     class ResolverCmd : public NetdCommand {
125     public:
126         ResolverCmd();
127         virtual ~ResolverCmd() {}
128         int runCommand(SocketClient *c, int argc, char ** argv);
129     };
130
131     class FirewallCmd: public NetdCommand {
132     public:
133         FirewallCmd();
134         virtual ~FirewallCmd() {}
135         int runCommand(SocketClient *c, int argc, char ** argv);
136     protected:
137         int sendGenericOkFail(SocketClient *cli, int cond);
138         static FirewallRule parseRule(const char* arg);
139     };
140
141     class ClatdCmd : public NetdCommand {
142     public:
143         ClatdCmd();
144         virtual ~ClatdCmd() {}
145         int runCommand(SocketClient *c, int argc, char ** argv);
146     };
147
148     class StrictCmd : public NetdCommand {
149     public:
150         StrictCmd();
151         virtual ~StrictCmd() {}
152         int runCommand(SocketClient *c, int argc, char ** argv);
153     protected:
154         int sendGenericOkFail(SocketClient *cli, int cond);
155         static StrictPenalty parsePenalty(const char* arg);
156     };
157
158     class NetworkCommand : public NetdCommand {
159     public:
160         NetworkCommand();
161         virtual ~NetworkCommand() {}
162         int runCommand(SocketClient* client, int argc, char** argv);
163     private:
164         int syntaxError(SocketClient* cli, const char* message);
165         int operationError(SocketClient* cli, const char* message, int ret);
166         int success(SocketClient* cli);
167     };
168 };
169
170 #endif