blob: d3bc2164001ce6fc49df44e5f129089981389a2c [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 Mehat5d6d4172009-05-14 15:00:06 -070016
San Mehat48765672009-05-20 15:28:43 -070017#include <stdio.h>
San Mehat5d6d4172009-05-14 15:00:06 -070018#include <string.h>
San Mehatdc266072009-05-06 11:16:52 -070019#include <errno.h>
San Mehat5d6d4172009-05-14 15:00:06 -070020#include <sys/socket.h>
21#include <netinet/in.h>
22#include <arpa/inet.h>
23
San Mehatdc266072009-05-06 11:16:52 -070024#include "VpnController.h"
25
26VpnController::VpnController() :
San Mehat48765672009-05-20 15:28:43 -070027 Controller("VPN", "vpn") {
28 registerProperty("gateway");
San Mehatdc266072009-05-06 11:16:52 -070029}
30
31int VpnController::start() {
San Mehat5d6d4172009-05-14 15:00:06 -070032 errno = ENOSYS;
San Mehatdc266072009-05-06 11:16:52 -070033 return -1;
34}
35
36int VpnController::stop() {
San Mehat5d6d4172009-05-14 15:00:06 -070037 errno = ENOSYS;
San Mehatdc266072009-05-06 11:16:52 -070038 return -1;
39}
40
41int VpnController::enable() {
San Mehat5d6d4172009-05-14 15:00:06 -070042 errno = ENOSYS;
San Mehatdc266072009-05-06 11:16:52 -070043 return -1;
44}
45
46int VpnController::disable() {
San Mehat5d6d4172009-05-14 15:00:06 -070047 errno = ENOSYS;
San Mehatdc266072009-05-06 11:16:52 -070048 return -1;
49}
San Mehat5d6d4172009-05-14 15:00:06 -070050
San Mehat48765672009-05-20 15:28:43 -070051int VpnController::setProperty(const char *name, char *value) {
52 if (!strcmp(name, "gateway")) {
53 if (!inet_aton(value, &mVpnGateway)) {
54 errno = EINVAL;
55 return -1;
56 }
57 return 0;
58 }
59
60 return Controller::setProperty(name, value);
San Mehat5d6d4172009-05-14 15:00:06 -070061}
62
San Mehat48765672009-05-20 15:28:43 -070063const char *VpnController::getProperty(const char *name, char *buffer, size_t maxsize) {
64 if (!strcmp(name, "gateway")) {
65 snprintf(buffer, maxsize, "%s", inet_ntoa(mVpnGateway));
66 return buffer;
67 }
68
69 return Controller::getProperty(name, buffer, maxsize);
San Mehat5d6d4172009-05-14 15:00:06 -070070}