OSDN Git Service

Drop PROHIBIT_NON_VPN priority 11500 -> 12500
[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 #include "utils/RWLock.h"
22
23 #include "NetdCommand.h"
24 #include "NetdConstants.h"
25 #include "NetworkController.h"
26 #include "TetherController.h"
27 #include "NatController.h"
28 #include "PppController.h"
29 #include "SoftapController.h"
30 #include "BandwidthController.h"
31 #include "IdletimerController.h"
32 #include "InterfaceController.h"
33 #include "ResolverController.h"
34 #include "FirewallController.h"
35 #include "ClatdController.h"
36 #include "StrictController.h"
37
38 class CommandListener : public FrameworkListener {
39 public:
40     CommandListener();
41     virtual ~CommandListener() {}
42
43 private:
44     void registerLockingCmd(FrameworkCommand *cmd, android::RWLock& lock);
45     void registerLockingCmd(FrameworkCommand *cmd) {
46         registerLockingCmd(cmd, android::net::gBigNetdLock);
47     }
48
49     class SoftapCmd : public NetdCommand {
50     public:
51         SoftapCmd();
52         virtual ~SoftapCmd() {}
53         int runCommand(SocketClient *c, int argc, char ** argv);
54     };
55
56     class InterfaceCmd : public NetdCommand {
57     public:
58         InterfaceCmd();
59         virtual ~InterfaceCmd() {}
60         int runCommand(SocketClient *c, int argc, char ** argv);
61     };
62
63     class IpFwdCmd : public NetdCommand {
64     public:
65         IpFwdCmd();
66         virtual ~IpFwdCmd() {}
67         int runCommand(SocketClient *c, int argc, char ** argv);
68     };
69
70     class TetherCmd : public NetdCommand {
71     public:
72         TetherCmd();
73         virtual ~TetherCmd() {}
74         int runCommand(SocketClient *c, int argc, char ** argv);
75     };
76
77     class NatCmd : public NetdCommand {
78     public:
79         NatCmd();
80         virtual ~NatCmd() {}
81         int runCommand(SocketClient *c, int argc, char ** argv);
82     };
83
84     class ListTtysCmd : public NetdCommand {
85     public:
86         ListTtysCmd();
87         virtual ~ListTtysCmd() {}
88         int runCommand(SocketClient *c, int argc, char ** argv);
89     };
90
91     class PppdCmd : public NetdCommand {
92     public:
93         PppdCmd();
94         virtual ~PppdCmd() {}
95         int runCommand(SocketClient *c, int argc, char ** argv);
96     };
97
98     class BandwidthControlCmd : public NetdCommand {
99     public:
100         BandwidthControlCmd();
101         virtual ~BandwidthControlCmd() {}
102         int runCommand(SocketClient *c, int argc, char ** argv);
103     protected:
104         void sendGenericOkFail(SocketClient *cli, int cond);
105         void sendGenericOpFailed(SocketClient *cli, const char *errMsg);
106         void sendGenericSyntaxError(SocketClient *cli, const char *usageMsg);
107     };
108
109     class IdletimerControlCmd : public NetdCommand {
110     public:
111         IdletimerControlCmd();
112         virtual ~IdletimerControlCmd() {}
113         int runCommand(SocketClient *c, int argc, char ** argv);
114     };
115
116     class ResolverCmd : public NetdCommand {
117     public:
118         ResolverCmd();
119         virtual ~ResolverCmd() {}
120         int runCommand(SocketClient *c, int argc, char ** argv);
121
122     private:
123         bool parseAndExecuteSetNetDns(int netId, int argc, const char** argv);
124     };
125
126     class FirewallCmd: public NetdCommand {
127     public:
128         FirewallCmd();
129         virtual ~FirewallCmd() {}
130         int runCommand(SocketClient *c, int argc, char ** argv);
131     protected:
132         int sendGenericOkFail(SocketClient *cli, int cond);
133         static FirewallRule parseRule(const char* arg);
134         static FirewallType parseFirewallType(const char* arg);
135         static ChildChain parseChildChain(const char* arg);
136     };
137
138     class ClatdCmd : public NetdCommand {
139     public:
140         ClatdCmd();
141         virtual ~ClatdCmd() {}
142         int runCommand(SocketClient *c, int argc, char ** argv);
143     };
144
145     class StrictCmd : public NetdCommand {
146     public:
147         StrictCmd();
148         virtual ~StrictCmd() {}
149         int runCommand(SocketClient *c, int argc, char ** argv);
150     protected:
151         int sendGenericOkFail(SocketClient *cli, int cond);
152         static StrictPenalty parsePenalty(const char* arg);
153     };
154
155     class NetworkCommand : public NetdCommand {
156     public:
157         NetworkCommand();
158         virtual ~NetworkCommand() {}
159         int runCommand(SocketClient* client, int argc, char** argv);
160     private:
161         int syntaxError(SocketClient* cli, const char* message);
162         int operationError(SocketClient* cli, const char* message, int ret);
163         int success(SocketClient* cli);
164     };
165 };
166
167 #endif