summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-04-23 14:49:12 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-04-23 14:49:12 +0100
commit6d6df9a7a4c1dfb794830c08629a9f89a1dea68c (patch)
tree1f091016635b0173554088c0cd1e2096cccf7ef6
parent0dd4cfa689fa50f12d954fd8e5698d66c1e115a6 (diff)
downloadconnman-6d6df9a7a4c1dfb794830c08629a9f89a1dea68c.tar.gz
connman-6d6df9a7a4c1dfb794830c08629a9f89a1dea68c.tar.bz2
connman-6d6df9a7a4c1dfb794830c08629a9f89a1dea68c.zip
Add extra unique identifier to service object path
-rw-r--r--src/detect.c14
-rw-r--r--src/service.c38
2 files changed, 40 insertions, 12 deletions
diff --git a/src/detect.c b/src/detect.c
index 9f3895df..0dce3d3f 100644
--- a/src/detect.c
+++ b/src/detect.c
@@ -157,7 +157,7 @@ static char *index2ident(int index, const char *prefix)
return NULL;
eth = (void *) &ifr.ifr_hwaddr.sa_data;
- snprintf(str, len, "%s%02X_%02X_%02X_%02X_%02X_%02X",
+ snprintf(str, len, "%s%02x%02x%02x%02x%02x%02x",
prefix ? prefix : "",
eth->ether_addr_octet[0],
eth->ether_addr_octet[1],
@@ -175,7 +175,7 @@ static void detect_newlink(unsigned short type, int index,
enum connman_device_type devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;
enum connman_device_mode mode = CONNMAN_DEVICE_MODE_UNKNOWN;
struct connman_device *device;
- gchar *addr, *name, *devname;
+ char *addr, *name, *devname, *ident;
DBG("type %d index %d", type, index);
@@ -264,19 +264,24 @@ static void detect_newlink(unsigned short type, int index,
case CONNMAN_DEVICE_TYPE_NOVATEL:
case CONNMAN_DEVICE_TYPE_GPS:
mode = CONNMAN_DEVICE_MODE_UNKNOWN;
+ ident = NULL;
break;
case CONNMAN_DEVICE_TYPE_ETHERNET:
mode = CONNMAN_DEVICE_MODE_TRANSPORT_IP;
+ ident = index2ident(index, NULL);
break;
case CONNMAN_DEVICE_TYPE_WIFI:
case CONNMAN_DEVICE_TYPE_WIMAX:
mode = CONNMAN_DEVICE_MODE_NETWORK_SINGLE;
+ ident = index2ident(index, NULL);
break;
case CONNMAN_DEVICE_TYPE_BLUETOOTH:
mode = CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE;
+ ident = NULL;
break;
case CONNMAN_DEVICE_TYPE_HSO:
mode = CONNMAN_DEVICE_MODE_NETWORK_SINGLE;
+ ident = NULL;
connman_device_set_policy(device, CONNMAN_DEVICE_POLICY_MANUAL);
break;
}
@@ -286,6 +291,11 @@ static void detect_newlink(unsigned short type, int index,
connman_device_set_index(device, index);
connman_device_set_interface(device, devname);
+ if (ident != NULL) {
+ connman_device_set_ident(device, ident);
+ g_free(ident);
+ }
+
connman_device_set_string(device, "Address", addr);
g_free(devname);
diff --git a/src/service.c b/src/service.c
index 57337bb9..77618146 100644
--- a/src/service.c
+++ b/src/service.c
@@ -729,10 +729,15 @@ static int service_register(struct connman_service *service)
struct connman_service *__connman_service_lookup_from_device(struct connman_device *device)
{
struct connman_service *service;
+ const char *ident;
char *name;
- name = g_strdup_printf("%s_%d", __connman_device_get_type(device),
- connman_device_get_index(device));
+ ident = __connman_device_get_ident(device);
+ if (ident == NULL)
+ return NULL;
+
+ name = g_strdup_printf("%s_%s",
+ __connman_device_get_type(device), ident);
service = connman_service_lookup(name);
@@ -773,10 +778,15 @@ static enum connman_service_type convert_device_type(struct connman_device *devi
struct connman_service *__connman_service_create_from_device(struct connman_device *device)
{
struct connman_service *service;
+ const char *ident;
char *name;
- name = g_strdup_printf("%s_%d", __connman_device_get_type(device),
- connman_device_get_index(device));
+ ident = __connman_device_get_ident(device);
+ if (ident == NULL)
+ return NULL;
+
+ name = g_strdup_printf("%s_%s",
+ __connman_device_get_type(device), ident);
service = connman_service_get(name);
if (service == NULL)
@@ -809,15 +819,19 @@ done:
struct connman_service *__connman_service_lookup_from_network(struct connman_network *network)
{
struct connman_service *service;
- const char *group;
+ const char *ident, *group;
char *name;
+ ident = __connman_network_get_ident(network);
+ if (ident == NULL)
+ return NULL;
+
group = __connman_network_get_group(network);
if (group == NULL)
return NULL;
- name = g_strdup_printf("%s_%s",
- __connman_network_get_type(network), group);
+ name = g_strdup_printf("%s_%s_%s",
+ __connman_network_get_type(network), ident, group);
service = connman_service_lookup(name);
@@ -924,15 +938,19 @@ static void update_from_network(struct connman_service *service,
struct connman_service *__connman_service_create_from_network(struct connman_network *network)
{
struct connman_service *service;
- const char *group;
+ const char *ident, *group;
char *name;
+ ident = __connman_network_get_ident(network);
+ if (ident == NULL)
+ return NULL;
+
group = __connman_network_get_group(network);
if (group == NULL)
return NULL;
- name = g_strdup_printf("%s_%s",
- __connman_network_get_type(network), group);
+ name = g_strdup_printf("%s_%s_%s",
+ __connman_network_get_type(network), ident, group);
service = connman_service_get(name);
if (service == NULL)