This email list is read-only. Emails sent to this list will be discarded
----------------------------------
include/dbus.h | 2 +
plugins/Makefile.am | 4 +-
plugins/resolvconf.c | 3 +-
plugins/resolvfile.c | 99 +++++++++++++++++++++++++++++++++++
plugins/wifi.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++--
src/Makefile.am | 4 +-
src/connman.h | 5 ++
src/main.c | 4 ++
src/manager.c | 26 +++++++++
src/profile.c | 118 +++++++++++++++++++++++++++++++++++++++++
test/Makefile.am | 2 +-
test/list-networks | 6 ++-
test/list-profiles | 22 ++++++++
13 files changed, 424 insertions(+), 12 deletions(-)
New commits:
commit f70d1758c876780c9dabe5b717550a54b194aab3
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Aug 7 10:23:16 2008 +0200
Add properties to the profile interface
commit 992a6e463a381c220b50f9ebfe36a14599c25834
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Aug 7 09:51:00 2008 +0200
Add resolver plugin for /etc/resolv.conf modifications
commit f3ce64de7eb5cffd32dafe6388b8425a5bec137a
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Aug 7 09:40:27 2008 +0200
Add object path for the default profile
commit efadc037b1fd86443fdff951214eb3b57a14c879
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Aug 7 09:24:22 2008 +0200
Add support for network scanning and selection
commit aa549a200ff5b44782935501dc1d0e20de62bd5d
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Aug 7 09:21:46 2008 +0200
Add initial skeleton for profile support
commit 5734f815db47e848c34bb84cd05293134652f635
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Thu Aug 7 04:10:12 2008 +0200
Show the connected value for each network
Diff in this email is a maximum of 400 lines.
diff --git a/include/dbus.h b/include/dbus.h
index be98a4e..a76aea2 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -36,6 +36,8 @@ extern "C" {
#define CONNMAN_ELEMENT_INTERFACE CONNMAN_SERVICE ".Element"
+#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile"
+
#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
#define CONNMAN_MANAGER_PATH "/"
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 121e05a..ea85755 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -2,7 +2,7 @@
plugindir = $(libdir)/connman/plugins
plugin_LTLIBRARIES = hal.la ethernet.la wifi.la bluetooth.la \
- dhclient.la ipv4.la resolvconf.la
+ dhclient.la ipv4.la resolvconf.la resolvfile.la
hal_la_SOURCES = hal.c
hal_la_LIBADD = @HAL_LIBS@
@@ -22,6 +22,8 @@ ipv4_la_SOURCES = ipv4.c
resolvconf_la_SOURCES = resolvconf.c
+resolvfile_la_SOURCES = resolvfile.c
+
AM_LDFLAGS = -no-undefined -module -avoid-version \
-export-symbols-regex connman_plugin_desc
diff --git a/plugins/resolvconf.c b/plugins/resolvconf.c
index b199646..1d4927b 100644
--- a/plugins/resolvconf.c
+++ b/plugins/resolvconf.c
@@ -72,8 +72,6 @@ static void resolvconf_remove(struct connman_element *element)
DBG("element %p name %s", element, element->name);
- DBG("element %p name %s", element, element->name);
-
connman_element_set_data(element, NULL);
connman_element_unregister(internet);
@@ -92,6 +90,7 @@ static void resolvconf_remove(struct connman_element *element)
static struct connman_driver resolvconf_driver = {
.name = "resolvconf",
.type = CONNMAN_ELEMENT_TYPE_RESOLVER,
+ .priority = CONNMAN_DRIVER_PRIORITY_HIGH,
.probe = resolvconf_probe,
.remove = resolvconf_remove,
};
diff --git a/plugins/resolvfile.c b/plugins/resolvfile.c
new file mode 100644
index 0000000..d39b2e1
--- /dev/null
+++ b/plugins/resolvfile.c
@@ -0,0 +1,99 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <connman/plugin.h>
+#include <connman/driver.h>
+#include <connman/log.h>
+
+static int resolvfile_probe(struct connman_element *element)
+{
+ const char *nameserver = NULL;
+ struct connman_element *internet;
+ gchar *cmd;
+ int err;
+
+ DBG("element %p name %s", element, element->name);
+
+ connman_element_get_value(element,
+ CONNMAN_PROPERTY_TYPE_IPV4_NAMESERVER, &nameserver);
+
+ if (nameserver == NULL)
+ return -EINVAL;
+
+ cmd = g_strdup_printf("echo \"nameserver %s\" > /etc/resolv.conf",
+ nameserver);
+
+ DBG("%s", cmd);
+
+ err = system(cmd);
+
+ g_free(cmd);
+
+ internet = connman_element_create();
+
+ internet->type = CONNMAN_ELEMENT_TYPE_INTERNET;
+
+ connman_element_set_data(element, internet);
+
+ connman_element_register(internet, element);
+
+ return 0;
+}
+
+static void resolvfile_remove(struct connman_element *element)
+{
+ struct connman_element *internet = connman_element_get_data(element);
+
+ DBG("element %p name %s", element, element->name);
+
+ connman_element_set_data(element, NULL);
+
+ connman_element_unregister(internet);
+
+ connman_element_unref(internet);
+}
+
+static struct connman_driver resolvfile_driver = {
+ .name = "resolvconf",
+ .type = CONNMAN_ELEMENT_TYPE_RESOLVER,
+ .priority = CONNMAN_DRIVER_PRIORITY_LOW,
+ .probe = resolvfile_probe,
+ .remove = resolvfile_remove,
+};
+
+static int resolvfile_init(void)
+{
+ return connman_driver_register(&resolvfile_driver);
+}
+
+static void resolvfile_exit(void)
+{
+ connman_driver_unregister(&resolvfile_driver);
+}
+
+CONNMAN_PLUGIN_DEFINE("resolvfile", "Name resolver plugin", VERSION,
+ resolvfile_init, resolvfile_exit)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 275a178..b4a3b8f 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -32,6 +32,72 @@
#include "supplicant.h"
+static struct connman_element *dhcp_element = NULL;
+
+static int network_probe(struct connman_element *element)
+{
+ DBG("element %p name %s", element, element->name);
+
+ return 0;
+}
+
+static void network_remove(struct connman_element *element)
+{
+ DBG("element %p name %s", element, element->name);
+}
+
+static int network_connect(struct connman_element *element)
+{
+ DBG("element %p name %s", element, element->name);
+
+ if (dhcp_element != NULL) {
+ connman_element_unregister(dhcp_element);
+ dhcp_element = NULL;
+ }
+
+ __supplicant_disconnect(element);
+
+ element->connected = FALSE;
+
+ connman_element_update(element);
+
+ g_free(element->parent->network.identifier);
+ element->parent->network.identifier = element->network.identifier;
+
+ if (__supplicant_connect(element, element->network.identifier) < 0)
+ connman_error("Failed to initiate connect");
+
+ return 0;
+}
+
+static int network_disconnect(struct connman_element *element)
+{
+ DBG("element %p name %s", element, element->name);
+
+ if (dhcp_element != NULL) {
+ connman_element_unregister(dhcp_element);
+ dhcp_element = NULL;
+ }
+
+ __supplicant_disconnect(element);
+
+ element->connected = FALSE;
+
+ connman_element_update(element);
+
+ return 0;
+}
+
+static struct connman_driver network_driver = {
+ .name = "wifi-network",
+ .type = CONNMAN_ELEMENT_TYPE_NETWORK,
+ .subtype = CONNMAN_ELEMENT_SUBTYPE_WIFI,
+ .probe = network_probe,
+ .remove = network_remove,
+ .connect = network_connect,
+ .disconnect = network_disconnect,
+};
+
struct wifi_data {
GStaticMutex mutex;
GSList *list;
@@ -56,6 +122,40 @@ static struct connman_element *find_element(struct
wifi_data *data,
return NULL;
}
+static void state_change(struct connman_element *parent,
+ enum supplicant_state state)
+{
+ struct wifi_data *data = connman_element_get_data(parent);
+ struct connman_element *element;
+
+ DBG("state %d", state);
+
+ if (parent->network.identifier == NULL)
+ return;
+
+ element = find_element(data, parent->network.identifier);
+ if (element == NULL)
+ return;
+
+ if (state == STATE_COMPLETED) {
+ struct connman_element *dhcp;
+
+ dhcp = connman_element_create();
+
+ dhcp->type = CONNMAN_ELEMENT_TYPE_DHCP;
+ dhcp->netdev.index = element->netdev.index;
+ dhcp->netdev.name = g_strdup(element->netdev.name);
+
+ dhcp_element = dhcp;
+
+ element->connected = TRUE;
+
+ connman_element_update(element);
+
+ connman_element_register(dhcp, element);
+ }
+}
+
static void scan_result(struct connman_element *parent,
struct supplicant_network *network)
{
@@ -78,21 +178,28 @@ static void scan_result(struct connman_element *parent,
temp = g_strdup(network->identifier);
for (i = 0; i < strlen(temp); i++) {
- if (temp[i] == ' ' || temp[i] == '.')
+ if (temp[i] == ' ' || temp[i] == '.' || temp[i] == '-')
+ temp[i] = '_';
+ if (temp[i] == '(' || temp[i] == ')')
+ temp[i] = '_';
+ if (g_ascii_isprint(temp[i]) == FALSE)
temp[i] = '_';
temp[i] = g_ascii_tolower(temp[i]);
}
g_static_mutex_lock(&data->mutex);
- element = find_element(data, temp);
+ element = find_element(data, network->identifier);
if (element == NULL) {
element = connman_element_create();
element->type = CONNMAN_ELEMENT_TYPE_NETWORK;
element->name = temp;
- element->network.identifier = g_strdup(temp);
+ element->network.identifier = g_strdup(network->identifier);
+
+ element->netdev.index = parent->netdev.index;
+ element->netdev.name = g_strdup(parent->netdev.name);
data->list = g_slist_append(data->list, element);
@@ -107,6 +214,7 @@ static void scan_result(struct connman_element *parent,
}
static struct supplicant_callback wifi_callback = {
+ .state_change = state_change,
.scan_result = scan_result,
};
@@ -164,21 +272,44 @@ static void wifi_remove(struct connman_element *element)
g_free(data);
}
+static int wifi_update(struct connman_element *element)
+{
+ DBG("element %p name %s", element, element->name);
+
+ __supplicant_scan(element);
+
+ return 0;
+}
+
static struct connman_driver wifi_driver = {
- .name = "wifi",
+ .name = "wifi-device",
.type = CONNMAN_ELEMENT_TYPE_DEVICE,
.subtype = CONNMAN_ELEMENT_SUBTYPE_WIFI,
.probe = wifi_probe,
.remove = wifi_remove,
+ .update = wifi_update,
};
static int wifi_init(void)
{
- return connman_driver_register(&wifi_driver);
+ int err;
+
+ err = connman_driver_register(&network_driver);
+ if (err < 0)
+ return err;
+
+ err = connman_driver_register(&wifi_driver);
+ if (err < 0) {
+ connman_driver_unregister(&network_driver);
+ return err;
+ }
+
+ return 0;
}
static void wifi_exit(void)
{
+ connman_driver_unregister(&network_driver);
connman_driver_unregister(&wifi_driver);
}
diff --git a/src/Makefile.am b/src/Makefile.am
index a1a7dac..e4ad954 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,8 +11,8 @@ DISTCLEANFILES = $(service_DATA)
sbin_PROGRAMS = connmand
-connmand_SOURCES = main.c connman.h log.c plugin.c element.c \
- storage.c manager.c agent.c
+connmand_SOURCES = main.c connman.h log.c plugin.c profile.c element.c \
+ storage.c manager.c agent.c
connmand_LDADD = @SQLITE_LIBS@ @GDBUS_LIBS@ @GMODULE_LIBS@ @GTHREAD_LIBS@
diff --git a/src/connman.h b/src/connman.h
index df1aabb..4249f33 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -39,6 +39,11 @@ void __connman_agent_cleanup(void);
int __connman_agent_register(const char *sender, const char *path);
int __connman_agent_unregister(const char *sender, const char *path);
+int __connman_profile_init(DBusConnection *conn);
+void __connman_profile_cleanup(void);
+
+void __connman_profile_list(DBusMessageIter *iter);
+
#include <connman/log.h>
int __connman_log_init(gboolean detach, gboolean debug);
diff --git a/src/main.c b/src/main.c
index 3a5990b..5f8b487 100644
--- a/src/main.c
_______________________________________________
Commits mailing list
[email protected]
https://www.moblin.org/mailman/listinfo/commits