Hi Otavio,

> A list of available interfaces of this technology
> ---
>  src/technology.c |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/src/technology.c b/src/technology.c
> index 2b34f50..a06382e 100644
> --- a/src/technology.c
> +++ b/src/technology.c
> @@ -59,6 +59,8 @@ struct connman_technology {
>       char *regdom;
>       connman_bool_t connected;
>  
> +     GSList *interface_list;
> +
>       connman_bool_t tethering;
>       char *tethering_ident;
>       char *tethering_passphrase;
> @@ -170,6 +172,21 @@ void connman_technology_driver_unregister(struct 
> connman_technology_driver *driv
>       driver_list = g_slist_remove(driver_list, driver);
>  }
>  
> +static void append_interfaces(DBusMessageIter *iter, void *user_data)
> +{
> +     struct connman_technology *technology = user_data;
> +     GSList *list;
> +
> +     for (list = technology->interface_list; list; list = list->next) {
> +             int index = GPOINTER_TO_INT(list->data);
> +             char *interface = connman_inet_ifname(index);
> +
> +             dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, 
> &interface);
> +
> +             g_free(interface);
> +     }

as I said before, this is pretty expensive operation. Too many syscalls
on every GetTechnologies call.

I tend to say that src/rtnl.c might need a global ifindex to name hash
table. That hash table then can also track renaming of interfaces.

> +}
> +
>  static void tethering_changed(struct connman_technology *technology)
>  {
>       connman_bool_t tethering = technology->tethering;
> @@ -432,6 +449,10 @@ static void append_properties(DBusMessageIter *iter,
>                                       DBUS_TYPE_BOOLEAN,
>                                       &technology->connected);
>  
> +     connman_dbus_dict_append_array(&dict, "Interfaces",
> +                                     DBUS_TYPE_STRING,
> +                                     append_interfaces, technology);
> +
>       connman_dbus_dict_append_basic(&dict, "Tethering",
>                                       DBUS_TYPE_BOOLEAN,
>                                       &technology->tethering);
> @@ -910,6 +931,8 @@ static struct connman_technology *technology_get(enum 
> connman_service_type type)
>  
>       technology->device_list = NULL;
>  
> +     technology->interface_list = NULL;
> +
>       technology->pending_reply = NULL;
>  
>       load_state(technology);
> @@ -959,6 +982,7 @@ static void technology_put(struct connman_technology 
> *technology)
>                                               CONNMAN_TECHNOLOGY_INTERFACE);
>  
>       g_slist_free(technology->device_list);
> +     g_slist_free(technology->interface_list);
>  
>       g_free(technology->path);
>       g_free(technology->regdom);
> @@ -990,6 +1014,9 @@ void __connman_technology_add_interface(enum 
> connman_service_type type,
>  
>       technology = technology_find(type);
>  
> +     if (technology != NULL)
> +             technology->interface_list = 
> g_slist_append(technology->interface_list, GINT_TO_POINTER(index));

Please stick to less than 80 chars per line.

> +
>       if (technology == NULL || technology->driver == NULL
>                       || technology->driver->add_interface == NULL)
>               return;

Also with this check we might can redo this a bit smarter.

        if (technology == NULL)
                return;

        technology->interface_list = g_slist_append(technology->interface,
                                                        GINT_TO_POINTER(index));

        if (technology->driver == NULL || ...)

> @@ -1028,6 +1055,8 @@ void __connman_technology_remove_interface(enum 
> connman_service_type type,
>  
>       if (technology->driver->remove_interface)
>               technology->driver->remove_interface(technology, index);
> +
> +     technology->interface_list = g_slist_remove(technology->interface_list, 
> GINT_TO_POINTER(index));

Please stick to less than 80 chars per line.

>  }
>  
>  int __connman_technology_add_device(struct connman_device *device)

Regards

Marcel


_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to