2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <sys/socket.h>
22 #include <netinet/in.h>
23 #include <arpa/inet.h>
25 #include "PropertyManager.h"
26 #include "VpnController.h"
28 VpnController::VpnController(PropertyManager *propmngr,
29 IControllerHandler *handlers) :
30 Controller("vpn", propmngr, handlers) {
33 mStaticProperties.propEnabled = new VpnEnabledProperty(this);
34 mDynamicProperties.propGateway = new IPV4AddressPropertyHelper("Gateway",
39 int VpnController::start() {
40 mPropMngr->attachProperty("vpn", mStaticProperties.propEnabled);
44 int VpnController::stop() {
45 mPropMngr->detachProperty("vpn", mStaticProperties.propEnabled);
49 VpnController::VpnIntegerProperty::VpnIntegerProperty(VpnController *c,
53 IntegerProperty(name, ro, elements) {
57 VpnController::VpnStringProperty::VpnStringProperty(VpnController *c,
59 bool ro, int elements) :
60 StringProperty(name, ro, elements) {
64 VpnController::VpnIPV4AddressProperty::VpnIPV4AddressProperty(VpnController *c,
66 bool ro, int elements) :
67 IPV4AddressProperty(name, ro, elements) {
71 VpnController::VpnEnabledProperty::VpnEnabledProperty(VpnController *c) :
72 VpnIntegerProperty(c, "Enabled", false, 1) {
74 int VpnController::VpnEnabledProperty::get(int idx, int *buffer) {
75 *buffer = mVc->mEnabled;
78 int VpnController::VpnEnabledProperty::set(int idx, int value) {
81 mVc->mPropMngr->detachProperty("vpn", mVc->mDynamicProperties.propGateway);
86 mVc->mPropMngr->attachProperty("vpn", mVc->mDynamicProperties.propGateway);
90 mVc->mEnabled = value;