diff options
| author | San Mehat <san@google.com> | 2009-05-20 15:28:43 -0700 |
|---|---|---|
| committer | San Mehat <san@google.com> | 2009-05-22 08:40:13 -0700 |
| commit | 4876567cb9c6a69ce21fd2b1c5bcce5a6f274276 (patch) | |
| tree | e08d76eed07e530884fb4e4d810a59ca4f017997 /nexus/VpnController.cpp | |
| parent | 463de48fb05cb29388e7763f75f6cfa56a2f5cb1 (diff) | |
| download | system_core-4876567cb9c6a69ce21fd2b1c5bcce5a6f274276.tar.gz system_core-4876567cb9c6a69ce21fd2b1c5bcce5a6f274276.tar.bz2 system_core-4876567cb9c6a69ce21fd2b1c5bcce5a6f274276.zip | |
nexus: Switch controllers to use abstracted properties and refactor command protocol
Also fixes a select() bug and removes debugging
Signed-off-by: San Mehat <san@google.com>
nexus: fix whitespace
Diffstat (limited to 'nexus/VpnController.cpp')
| -rw-r--r-- | nexus/VpnController.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
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 <stdio.h> #include <string.h> #include <errno.h> #include <sys/socket.h> @@ -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); } |
