OSDN Git Service

When un-natting try to do all we can
[android-x86/system-netd.git] / 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 "TetherController.h"
24 #include "NatController.h"
25 #include "PppController.h"
26 #include "PanController.h"
27 #include "SoftapController.h"
28 #include "BandwidthController.h"
29 #include "ResolverController.h"
30
31 class CommandListener : public FrameworkListener {
32     static TetherController *sTetherCtrl;
33     static NatController *sNatCtrl;
34     static PppController *sPppCtrl;
35     static PanController *sPanCtrl;
36     static SoftapController *sSoftapCtrl;
37     static BandwidthController *sBandwidthCtrl;
38     static ResolverController *sResolverCtrl;
39
40 public:
41     CommandListener();
42     virtual ~CommandListener() {}
43
44 private:
45
46     static int writeFile(const char *path, const char *value, int size);
47
48     static int readInterfaceCounters(const char *iface, unsigned long *rx, unsigned long *tx);
49
50     class SoftapCmd : public NetdCommand {
51     public:
52         SoftapCmd();
53         virtual ~SoftapCmd() {}
54         int runCommand(SocketClient *c, int argc, char ** argv);
55     };
56
57     class InterfaceCmd : public NetdCommand {
58     public:
59         InterfaceCmd();
60         virtual ~InterfaceCmd() {}
61         int runCommand(SocketClient *c, int argc, char ** argv);
62     };
63
64     class IpFwdCmd : public NetdCommand {
65     public:
66         IpFwdCmd();
67         virtual ~IpFwdCmd() {}
68         int runCommand(SocketClient *c, int argc, char ** argv);
69     };
70
71     class TetherCmd : public NetdCommand {
72     public:
73         TetherCmd();
74         virtual ~TetherCmd() {}
75         int runCommand(SocketClient *c, int argc, char ** argv);
76     };
77
78     class NatCmd : public NetdCommand {
79     public:
80         NatCmd();
81         virtual ~NatCmd() {}
82         int runCommand(SocketClient *c, int argc, char ** argv);
83     };
84
85     class ListTtysCmd : public NetdCommand {
86     public:
87         ListTtysCmd();
88         virtual ~ListTtysCmd() {}
89         int runCommand(SocketClient *c, int argc, char ** argv);
90     };
91
92     class PppdCmd : public NetdCommand {
93     public:
94         PppdCmd();
95         virtual ~PppdCmd() {}
96         int runCommand(SocketClient *c, int argc, char ** argv);
97     };
98
99     class PanCmd : public NetdCommand {
100     public:
101         PanCmd();
102         virtual ~PanCmd() {}
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 ResolverCmd : public NetdCommand {
118     public:
119         ResolverCmd();
120         virtual ~ResolverCmd() {}
121         int runCommand(SocketClient *c, int argc, char ** argv);
122     };
123 };
124
125 #endif