#include <connman/driver.h>
#include <connman/element.h>
-int __connman_element_init(DBusConnection *conn);
+int __connman_element_init(DBusConnection *conn, const char *device);
void __connman_element_cleanup(void);
void __connman_element_list(enum connman_element_type type,
static GThreadPool *thread_register = NULL;
static GThreadPool *thread_unregister = NULL;
+static gchar *device_filter = NULL;
+
static const char *type2string(enum connman_element_type type)
{
switch (type) {
{
DBG("element %p name %s parent %p", element, element->name, parent);
+ if (device_filter && element->type == CONNMAN_ELEMENT_TYPE_DEVICE) {
+ if (g_str_equal(device_filter, element->netdev.name) == FALSE)
+ return -EINVAL;
+ }
+
if (connman_element_ref(element) == NULL)
return -EINVAL;
connman_element_unref(element);
}
-int __connman_element_init(DBusConnection *conn)
+int __connman_element_init(DBusConnection *conn, const char *device)
{
struct connman_element *element;
if (connection == NULL)
return -EIO;
+ device_filter = g_strdup(device);
+
g_static_rw_lock_writer_lock(&element_lock);
element = connman_element_create();
element_root = NULL;
g_static_rw_lock_writer_unlock(&element_lock);
+ g_free(device_filter);
+
dbus_connection_unref(connection);
}
g_main_loop_quit(main_loop);
}
-static gchar *option_interface = NULL;
+static gchar *option_device = NULL;
static gboolean option_detach = TRUE;
static gboolean option_compat = FALSE;
static gboolean option_debug = FALSE;
static GOptionEntry options[] = {
- { "interface", 'i', 0, G_OPTION_ARG_STRING, &option_interface,
- "Specify network interface", "IFACE" },
+ { "device", 'i', 0, G_OPTION_ARG_STRING, &option_device,
+ "Specify network device/interface", "DEV" },
{ "nodaemon", 'n', G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &option_detach,
"Don't fork daemon to background" },
__connman_storage_init();
- __connman_element_init(conn);
+ __connman_element_init(conn, option_device);
__connman_agent_init(conn);
__connman_plugin_init();
- g_free(option_interface);
+ g_free(option_device);
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sig_term;