CommandListener.h revision 8e46896b4c4be5deaef651a12b17314f63ae9070
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 "UsbController.h"
29
30class CommandListener : public FrameworkListener {
31    static TetherController *sTetherCtrl;
32    static NatController *sNatCtrl;
33    static PppController *sPppCtrl;
34    static PanController *sPanCtrl;
35    static SoftapController *sSoftapCtrl;
36    static UsbController *sUsbCtrl;
37
38public:
39    CommandListener();
40    virtual ~CommandListener() {}
41
42private:
43
44    static int readInterfaceCounters(const char *iface, unsigned long *rx, unsigned long *tx);
45
46    class UsbCmd : public NetdCommand {
47    public:
48        UsbCmd();
49        virtual ~UsbCmd() {}
50        int runCommand(SocketClient *c, int argc, char ** argv);
51    };
52
53    class SoftapCmd : public NetdCommand {
54    public:
55        SoftapCmd();
56        virtual ~SoftapCmd() {}
57        int runCommand(SocketClient *c, int argc, char ** argv);
58    };
59
60    class InterfaceCmd : public NetdCommand {
61    public:
62        InterfaceCmd();
63        virtual ~InterfaceCmd() {}
64        int runCommand(SocketClient *c, int argc, char ** argv);
65    };
66
67    class IpFwdCmd : public NetdCommand {
68    public:
69        IpFwdCmd();
70        virtual ~IpFwdCmd() {}
71        int runCommand(SocketClient *c, int argc, char ** argv);
72    };
73
74    class TetherCmd : public NetdCommand {
75    public:
76        TetherCmd();
77        virtual ~TetherCmd() {}
78        int runCommand(SocketClient *c, int argc, char ** argv);
79    };
80
81    class NatCmd : public NetdCommand {
82    public:
83        NatCmd();
84        virtual ~NatCmd() {}
85        int runCommand(SocketClient *c, int argc, char ** argv);
86    };
87
88    class ListTtysCmd : public NetdCommand {
89    public:
90        ListTtysCmd();
91        virtual ~ListTtysCmd() {}
92        int runCommand(SocketClient *c, int argc, char ** argv);
93    };
94
95    class PppdCmd : public NetdCommand {
96    public:
97        PppdCmd();
98        virtual ~PppdCmd() {}
99        int runCommand(SocketClient *c, int argc, char ** argv);
100    };
101
102    class PanCmd : public NetdCommand {
103    public:
104        PanCmd();
105        virtual ~PanCmd() {}
106        int runCommand(SocketClient *c, int argc, char ** argv);
107    };
108};
109
110#endif
111