diff options
-rw-r--r-- | include/technology.h | 4 | ||||
-rw-r--r-- | src/connman.h | 4 | ||||
-rw-r--r-- | src/rtnl.c | 8 | ||||
-rw-r--r-- | src/technology.c | 73 |
4 files changed, 85 insertions, 4 deletions
diff --git a/include/technology.h b/include/technology.h index 7638454b..256a2eb5 100644 --- a/include/technology.h +++ b/include/technology.h @@ -42,6 +42,10 @@ struct connman_technology_driver { int priority; int (*probe) (struct connman_technology *technology); void (*remove) (struct connman_technology *technology); + void (*add_interface) (struct connman_technology *technology, + int index, const char *name); + void (*remove_interface) (struct connman_technology *technology, + int index); int (*set_tethering) (struct connman_technology *technology, connman_bool_t enabled); }; diff --git a/src/connman.h b/src/connman.h index ebd94b3e..6b9a34a7 100644 --- a/src/connman.h +++ b/src/connman.h @@ -301,6 +301,10 @@ int __connman_technology_update_rfkill(unsigned int index, connman_bool_t hardblock); int __connman_technology_remove_rfkill(unsigned int index); +void __connman_technology_add_interface(enum connman_service_type type, + int index, const char *name); +void __connman_technology_remove_interface(enum connman_service_type type, + int index, const char *name); int __connman_technology_enable_tethering(void); int __connman_technology_disable_tethering(void); @@ -68,8 +68,8 @@ static void free_interface(gpointer data) { struct interface_data *interface = data; - connman_info("Remove interface %s [ %s ]", interface->name, - __connman_service_type2string(interface->type)); + __connman_technology_remove_interface(interface->type, + interface->index, interface->name); g_free(interface->name); g_free(interface); @@ -388,8 +388,8 @@ static void process_newlink(unsigned short type, int index, unsigned flags, read_uevent(interface); - connman_info("Create interface %s [ %s ]", interface->name, - __connman_service_type2string(interface->type)); + __connman_technology_add_interface(interface->type, + interface->index, interface->name); } for (list = rtnl_list; list; list = list->next) { diff --git a/src/technology.c b/src/technology.c index 0ee91a39..34c50be6 100644 --- a/src/technology.c +++ b/src/technology.c @@ -100,6 +100,79 @@ void connman_technology_driver_unregister(struct connman_technology_driver *driv driver_list = g_slist_remove(driver_list, driver); } +void __connman_technology_add_interface(enum connman_service_type type, + int index, const char *name) +{ + GSList *list; + + switch (type) { + case CONNMAN_SERVICE_TYPE_UNKNOWN: + case CONNMAN_SERVICE_TYPE_SYSTEM: + return; + case CONNMAN_SERVICE_TYPE_ETHERNET: + case CONNMAN_SERVICE_TYPE_WIFI: + case CONNMAN_SERVICE_TYPE_WIMAX: + case CONNMAN_SERVICE_TYPE_BLUETOOTH: + case CONNMAN_SERVICE_TYPE_CELLULAR: + case CONNMAN_SERVICE_TYPE_GPS: + case CONNMAN_SERVICE_TYPE_VPN: + break; + } + + connman_info("Create interface %s [ %s ]", name, + __connman_service_type2string(type)); + + for (list = technology_list; list; list = list->next) { + struct connman_technology *technology = list->data; + + if (technology->type != type) + continue; + + if (technology->driver == NULL) + continue; + + if (technology->driver->add_interface) + technology->driver->add_interface(technology, + index, name); + } +} + +void __connman_technology_remove_interface(enum connman_service_type type, + int index, const char *name) +{ + GSList *list; + + switch (type) { + case CONNMAN_SERVICE_TYPE_UNKNOWN: + case CONNMAN_SERVICE_TYPE_SYSTEM: + return; + case CONNMAN_SERVICE_TYPE_ETHERNET: + case CONNMAN_SERVICE_TYPE_WIFI: + case CONNMAN_SERVICE_TYPE_WIMAX: + case CONNMAN_SERVICE_TYPE_BLUETOOTH: + case CONNMAN_SERVICE_TYPE_CELLULAR: + case CONNMAN_SERVICE_TYPE_GPS: + case CONNMAN_SERVICE_TYPE_VPN: + break; + } + + connman_info("Remove interface %s [ %s ]", name, + __connman_service_type2string(type)); + + for (list = technology_list; list; list = list->next) { + struct connman_technology *technology = list->data; + + if (technology->type != type) + continue; + + if (technology->driver == NULL) + continue; + + if (technology->driver->remove_interface) + technology->driver->remove_interface(technology, index); + } +} + static int set_tethering(connman_bool_t enabled) { GSList *list; |