From 4876567cb9c6a69ce21fd2b1c5bcce5a6f274276 Mon Sep 17 00:00:00 2001 From: San Mehat Date: Wed, 20 May 2009 15:28:43 -0700 Subject: nexus: Switch controllers to use abstracted properties and refactor command protocol Also fixes a select() bug and removes debugging Signed-off-by: San Mehat nexus: fix whitespace --- nexus/VpnController.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'nexus/VpnController.cpp') diff --git a/nexus/VpnController.cpp b/nexus/VpnController.cpp index cd24c19e..d3bc2164 100644 --- a/nexus/VpnController.cpp +++ b/nexus/VpnController.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -23,7 +24,8 @@ #include "VpnController.h" VpnController::VpnController() : - Controller("VPN") { + Controller("VPN", "vpn") { + registerProperty("gateway"); } int VpnController::start() { @@ -46,15 +48,23 @@ int VpnController::disable() { return -1; } -int VpnController::setVpnGateway(const char *vpnGw) { - if (!inet_aton(vpnGw, &mVpnGateway)) { - errno = EINVAL; - return -1; - } - return 0; +int VpnController::setProperty(const char *name, char *value) { + if (!strcmp(name, "gateway")) { + if (!inet_aton(value, &mVpnGateway)) { + errno = EINVAL; + return -1; + } + return 0; + } + + return Controller::setProperty(name, value); } -int VpnController::setVpnGateway(struct in_addr *vpnGw) { - memcpy(&mVpnGateway, vpnGw, sizeof(struct in_addr)); - return 0; +const char *VpnController::getProperty(const char *name, char *buffer, size_t maxsize) { + if (!strcmp(name, "gateway")) { + snprintf(buffer, maxsize, "%s", inet_ntoa(mVpnGateway)); + return buffer; + } + + return Controller::getProperty(name, buffer, maxsize); } -- cgit v1.2.3