blob: 4bd86b54de01ab7d1f230363967fb95b554f47b9 [file] [log] [blame]
San Mehatdc266072009-05-06 11:16:52 -07001/*
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 */
San Mehat3c5a6f02009-05-22 15:36:13 -070016
San Mehatdc266072009-05-06 11:16:52 -070017#ifndef _VPN_CONTROLLER_H
18#define _VPN_CONTROLLER_H
19
San Mehat5d6d4172009-05-14 15:00:06 -070020#include <netinet/in.h>
21
San Mehatdc266072009-05-06 11:16:52 -070022#include "Controller.h"
23
San Mehat3aff2d12009-06-15 14:10:44 -070024class IControllerHandler;
25
San Mehatdc266072009-05-06 11:16:52 -070026class VpnController : public Controller {
San Mehatc4a895b2009-06-23 21:10:57 -070027 class VpnIntegerProperty : public IntegerProperty {
28 protected:
29 VpnController *mVc;
30 public:
31 VpnIntegerProperty(VpnController *c, const char *name, bool ro,
32 int elements);
33 virtual ~VpnIntegerProperty() {}
34 virtual int set(int idx, int value) = 0;
35 virtual int get(int idx, int *buffer) = 0;
36 };
37 friend class VpnController::VpnIntegerProperty;
38
39 class VpnStringProperty : public StringProperty {
40 protected:
41 VpnController *mVc;
42 public:
43 VpnStringProperty(VpnController *c, const char *name, bool ro,
44 int elements);
45 virtual ~VpnStringProperty() {}
46 virtual int set(int idx, const char *value) = 0;
47 virtual int get(int idx, char *buffer, size_t max) = 0;
48 };
49 friend class VpnController::VpnStringProperty;
50
51 class VpnIPV4AddressProperty : public IPV4AddressProperty {
52 protected:
53 VpnController *mVc;
54 public:
55 VpnIPV4AddressProperty(VpnController *c, const char *name, bool ro,
56 int elements);
57 virtual ~VpnIPV4AddressProperty() {}
58 virtual int set(int idx, struct in_addr *value) = 0;
59 virtual int get(int idx, struct in_addr *buffer) = 0;
60 };
61 friend class VpnController::VpnIPV4AddressProperty;
62
63 class VpnEnabledProperty : public VpnIntegerProperty {
64 public:
65 VpnEnabledProperty(VpnController *c);
66 virtual ~VpnEnabledProperty() {};
67 int set(int idx, int value);
68 int get(int idx, int *buffer);
69 };
70
San Mehat3c5a6f02009-05-22 15:36:13 -070071 bool mEnabled;
San Mehat5d6d4172009-05-14 15:00:06 -070072 /*
73 * Gateway of the VPN server to connect to
74 */
San Mehatc4a895b2009-06-23 21:10:57 -070075 struct in_addr mGateway;
76
77 struct {
78 VpnEnabledProperty *propEnabled;
79 } mStaticProperties;
80
81 struct {
82 IPV4AddressPropertyHelper *propGateway;
83 } mDynamicProperties;
San Mehatdc266072009-05-06 11:16:52 -070084
85public:
San Mehat3aff2d12009-06-15 14:10:44 -070086 VpnController(PropertyManager *propmngr, IControllerHandler *handlers);
San Mehatdc266072009-05-06 11:16:52 -070087 virtual ~VpnController() {}
88
89 virtual int start();
90 virtual int stop();
91
San Mehat3c5a6f02009-05-22 15:36:13 -070092protected:
93 virtual int enable() = 0;
94 virtual int disable() = 0;
San Mehatdc266072009-05-06 11:16:52 -070095};
96
97#endif