summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-02-26 23:45:29 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-02-26 23:45:29 +0100
commit72ed7e7dd6a3b944c7edc35c407b719aa679fbca (patch)
tree46b7bb0885e7283e981a97f891fa9e9f70efec2e /src
parentfa7a1adf087f2dec6cbea91dac2e1c63a1c9cb52 (diff)
downloadconnman-72ed7e7dd6a3b944c7edc35c407b719aa679fbca.tar.gz
connman-72ed7e7dd6a3b944c7edc35c407b719aa679fbca.tar.bz2
connman-72ed7e7dd6a3b944c7edc35c407b719aa679fbca.zip
Convert identifier on-demand if needed
Diffstat (limited to 'src')
-rw-r--r--src/device.c21
-rw-r--r--src/network.c17
2 files changed, 36 insertions, 2 deletions
diff --git a/src/device.c b/src/device.c
index 8427a2c9..701528fc 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1449,9 +1449,28 @@ int connman_device_add_network(struct connman_device *device,
struct connman_network *connman_device_get_network(struct connman_device *device,
const char *identifier)
{
+ struct connman_network *network;
+ char *temp;
+ unsigned int i;
+
DBG("device %p identifier %s", device, identifier);
- return g_hash_table_lookup(device->networks, identifier);
+ temp = g_strdup(identifier);
+ if (temp == NULL)
+ return NULL;
+
+ for (i = 0; i < strlen(temp); i++) {
+ char tmp = temp[i];
+ if ((tmp < '0' || tmp > '9') && (tmp < 'A' || tmp > 'Z') &&
+ (tmp < 'a' || tmp > 'z'))
+ temp[i] = '_';
+ }
+
+ network = g_hash_table_lookup(device->networks, temp);
+
+ g_free(temp);
+
+ return network;
}
/**
diff --git a/src/network.c b/src/network.c
index e5b2ae5e..66158e98 100644
--- a/src/network.c
+++ b/src/network.c
@@ -447,6 +447,8 @@ struct connman_network *connman_network_create(const char *identifier,
struct connman_network *network;
connman_uint8_t strength = 0;
const char *str;
+ char *temp;
+ unsigned int i;
DBG("identifier %s type %d", identifier, type);
@@ -458,7 +460,20 @@ struct connman_network *connman_network_create(const char *identifier,
__connman_element_initialize(&network->element);
- network->element.name = g_strdup(identifier);
+ temp = g_strdup(identifier);
+ if (temp == NULL) {
+ g_free(network);
+ return NULL;
+ }
+
+ for (i = 0; i < strlen(temp); i++) {
+ char tmp = temp[i];
+ if ((tmp < '0' || tmp > '9') && (tmp < 'A' || tmp > 'Z') &&
+ (tmp < 'a' || tmp > 'z'))
+ temp[i] = '_';
+ }
+
+ network->element.name = temp;
network->element.type = CONNMAN_ELEMENT_TYPE_NETWORK;
network->element.network = network;