diff options
| author | San Mehat <san@google.com> | 2009-05-22 15:36:13 -0700 |
|---|---|---|
| committer | San Mehat <san@google.com> | 2009-05-29 15:26:21 -0700 |
| commit | 3c5a6f0bc8aefc4dacab8e95ba9017a7ac7d91f5 (patch) | |
| tree | e73708dde1e774c8e6a0539a91a228acd68000a2 /nexus/Controller.cpp | |
| parent | 192331d9060763b92f7989124bedbd136689d735 (diff) | |
| download | system_core-3c5a6f0bc8aefc4dacab8e95ba9017a7ac7d91f5.tar.gz system_core-3c5a6f0bc8aefc4dacab8e95ba9017a7ac7d91f5.tar.bz2 system_core-3c5a6f0bc8aefc4dacab8e95ba9017a7ac7d91f5.zip | |
nexus: Refactor some of the create/remove network path and add code for
retrieving network lists from supplicant
nexus: Rework properties
nexus: Implement wifi network enable/disable and add some error checking
nexus: Add some TODOs
nexus: Whitespace cleanup
nexus: Add bindings between controllers and network interfaces
nexus: Add properties for InterfaceConfig
nexus: Fix a few conversion bugs in InterfaceConfig
Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'nexus/Controller.cpp')
| -rw-r--r-- | nexus/Controller.cpp | 85 |
1 files changed, 27 insertions, 58 deletions
diff --git a/nexus/Controller.cpp b/nexus/Controller.cpp index 133e796e..9d4ff3c6 100644 --- a/nexus/Controller.cpp +++ b/nexus/Controller.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -33,13 +34,17 @@ extern "C" int init_module(void *, unsigned int, const char *); extern "C" int delete_module(const char *, unsigned int); -Controller::Controller(const char *name, const char *prefix) { - mName = name; - mPropertyPrefix = prefix; - mProperties = new PropertyCollection(); +Controller::Controller(const char *name, PropertyManager *propMngr) { + mPropMngr = propMngr; + mName = strdup(name); + mBoundInterface = NULL; +} - mEnabled = false; - registerProperty("enable"); +Controller::~Controller() { + if (mBoundInterface) + free(mBoundInterface); + if (mName) + free(mName); } int Controller::start() { @@ -50,65 +55,16 @@ int Controller::stop() { return 0; } -const PropertyCollection & Controller::getProperties() { - return *mProperties; -} - -int Controller::setProperty(const char *name, char *value) { - if (!strcmp(name, "enable")) { - int en = atoi(value); - int rc; - - rc = (en ? enable() : disable()); - - if (!rc) - mEnabled = en; - - return rc; - } - +int Controller::set(const char *name, const char *value) { errno = ENOENT; return -1; } -const char *Controller::getProperty(const char *name, char *buffer, size_t maxsize) { - if (!strcmp(name, "enable")) { - snprintf(buffer, maxsize, "%d", mEnabled); - return buffer; - } - +const char *Controller::get(const char *name, char *buffer, size_t maxsize) { errno = ENOENT; return NULL; } -int Controller::registerProperty(const char *name) { - PropertyCollection::iterator it; - - for (it = mProperties->begin(); it != mProperties->end(); ++it) { - if (!strcmp(name, (*it))) { - errno = EADDRINUSE; - LOGE("Failed to register property (%s)", strerror(errno)); - return -1; - } - } - - mProperties->push_back(name); - return 0; -} - -int Controller::unregisterProperty(const char *name) { - PropertyCollection::iterator it; - - for (it = mProperties->begin(); it != mProperties->end(); ++it) { - if (!strcmp(name, (*it))) { - mProperties->erase(it); - return 0; - } - } - errno = ENOENT; - return -1; -} - int Controller::loadKernelModule(char *modpath, const char *args) { void *module; unsigned int size; @@ -137,7 +93,7 @@ int Controller::unloadKernelModule(const char *modtag) { } if (rc != 0) { - LOGW("Unable to unload kernel driver '%s' (%s)", modtag, + LOGW("Unable to unload kernel driver '%s' (%s)", modtag, strerror(errno)); } return rc; @@ -203,3 +159,16 @@ bail: close(fd); return buffer; } + +int Controller::bindInterface(const char *ifname) { + mBoundInterface = strdup(ifname); + LOGD("Controller %s bound to %s", mName, ifname); + return 0; +} + +int Controller::unbindInterface(const char *ifname) { + free(mBoundInterface); + mBoundInterface = NULL; + LOGD("Controller %s unbound from %s", mName, ifname); + return 0; +} |
