This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 doc/device-api.txt  |   24 +++--
 include/device.h    |    8 +-
 plugins/Makefile.am |    8 +-
 plugins/hso.c       |   60 +++++++++++
 plugins/rtnllink.c  |  185 ----------------------------------
 src/Makefile.am     |    5 +-
 src/connman.h       |    4 +
 src/detect.c        |  275 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/device.c        |  139 +++++++++++++++++++++++---
 src/element.c       |    9 ++
 src/main.c          |    2 +
 test/Makefile.am    |    2 +-
 test/disable-device |   11 ++-
 test/enable-device  |   11 ++-
 test/set-policy     |   28 +++++
 15 files changed, 548 insertions(+), 223 deletions(-)

New commits:
commit 4ce9f90d4d689d492cd9650e55bf615699e1616f
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 02:59:16 2008 +0100

    Add support for changing policy over D-Bus

commit 9f5303e643adbfeb9a636c0f800509ebfd33f66c
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 02:58:21 2008 +0100

    Add device argument to enable and disable scripts

commit dba2854c4a36e8848aeec7b1e7d8c24b17147222
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 02:54:09 2008 +0100

    Add test script for changing device policy

commit 0e0df318a9d596ebe32f6691418e99f2eb750e40
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 02:25:37 2008 +0100

    Enable devices when policy is set to manual

commit f1ccee1d9e378a3a0fe8d75afc947d5d42ce0aa1
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 02:22:14 2008 +0100

    Set manual policy for Bluetooth and HSO devices as default

commit c5d973cf54a9fe54ec4e82a5780144b3b1f0afb0
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 02:18:36 2008 +0100

    Add function to change initial policy setting

commit c867b6b07870792c5efe275e2f79cb9ba9595164
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 02:13:50 2008 +0100

    Add manual policy to device settings

commit f0444b7be4f6b38137796489b2c6a258b431af27
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 10:33:06 2008 +0100

    Classify HSO devices as cellular

commit d3327fdbc45b8c5509e5a680dca367c945e9bd47
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 09:05:02 2008 +0100

    Add skeleton for Option HSO driver

commit 21a89f85e212d694db038a201aebbcccb90a3c5b
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 09:03:59 2008 +0100

    Use interface name as device name for HSO devices

commit 7e090d498e11ae435d973bea44e393a6e42beb3d
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 08:54:35 2008 +0100

    Add basic detection of Option HSO devices

commit a5a91a7189c48532309888a150e973fed1f12852
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 08:44:05 2008 +0100

    Remove unused statement

commit 3d52695c2fa60c2e8cb6b7bc4af5aeb504981974
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 08:41:14 2008 +0100

    Add generic device detection support

commit a63f375583ede1f9b42626dc145db3fa657ea3ae
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 08:39:11 2008 +0100

    Remove RTNL link detection plugin

commit ebbf5aeca9880a3dce73effa17ba13caf3be3837
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 08:26:12 2008 +0100

    Add stage for stopping element registration

commit fd31f66180b7960edb1283bcbc80897eca134a03
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 27 07:00:31 2008 +0100

    Register device interface only when driver is bound


Diff in this email is a maximum of 400 lines.
diff --git a/doc/device-api.txt b/doc/device-api.txt
index 7d1b86f..6d8f348 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -63,21 +63,29 @@ Properties  string Name [readonly]
 
                string Policy [readwrite]
 
-                       Setting of the device power policy. Possible values
-                       are "off", "ignore" and "auto".
+                       Setting of the device power and connection policy.
+                       Possible values are "ignore", "off", "auto"
+                       and "manual".
 
                        The policy defines on how the device is initialized
-                       when brought up. The actual device power state can
-                       be changed independently to this value.
+                       when brought up and how it connects. The actual
+                       device power state can be changed independently to
+                       this value.
 
                        If a device is switched off and the policy is changed
-                       to "auto", the device will be switched. For a current
-                       active device changing the policy to "off" results
-                       in powering down the device.
+                       to "auto" or "manual", the device will be switched
+                       on. For a current active device changing the policy
+                       to "off" results in powering down the device.
 
                        The "ignore" policy can be set for devices that are
                        detected, but managed by a different entity on the
-                       system. For example complex network setups.
+                       system. For example for complex network setups.
+
+                       Devices that can connect to various networks, the
+                       difference between "auto" or "manual" defines if
+                       known networks are connected automatically or not.
+                       For simple devices like Ethernet cards, setting
+                       the "manual" policy might fail.
 
                boolean Powered [readwrite]
 
diff --git a/include/device.h b/include/device.h
index 95ffeee..6d172e8 100644
--- a/include/device.h
+++ b/include/device.h
@@ -44,6 +44,7 @@ enum connman_device_type {
        CONNMAN_DEVICE_TYPE_MODEM     = CONNMAN_ELEMENT_SUBTYPE_MODEM,
        CONNMAN_DEVICE_TYPE_BLUETOOTH = CONNMAN_ELEMENT_SUBTYPE_BLUETOOTH,
        CONNMAN_DEVICE_TYPE_VENDOR    = 42,
+       CONNMAN_DEVICE_TYPE_HSO,
 };
 
 enum connman_device_mode {
@@ -55,8 +56,9 @@ enum connman_device_mode {
 enum connman_device_policy {
        CONNMAN_DEVICE_POLICY_UNKNOWN = 0,
        CONNMAN_DEVICE_POLICY_IGNORE  = 1,
-       CONNMAN_DEVICE_POLICY_AUTO    = 2,
-       CONNMAN_DEVICE_POLICY_OFF     = 3,
+       CONNMAN_DEVICE_POLICY_OFF     = 2,
+       CONNMAN_DEVICE_POLICY_AUTO    = 3,
+       CONNMAN_DEVICE_POLICY_MANUAL  = 4,
 };
 
 struct connman_device;
@@ -76,6 +78,8 @@ extern void connman_device_set_interface(struct 
connman_device *device,
                                                        const char *interface);
 extern const char *connman_device_get_interface(struct connman_device *device);
 
+extern void connman_device_set_policy(struct connman_device *device,
+                                       enum connman_device_policy policy);
 extern void connman_device_set_mode(struct connman_device *device,
                                                enum connman_device_mode mode);
 
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2cde74b..09ca6f7 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,8 +1,8 @@
 
 plugindir = $(libdir)/connman/plugins
 
-plugin_LTLIBRARIES = loopback.la netdev.la ethernet.la wifi.la bluetooth.la \
-                               udhcp.la dhclient.la ipv4.la rtnllink.la \
+plugin_LTLIBRARIES = loopback.la netdev.la ethernet.la wifi.la \
+                       bluetooth.la hso.la udhcp.la dhclient.la ipv4.la \
                                dnsproxy.la resolvconf.la resolvfile.la
 
 loopback_la_SOURCES = loopback.c
@@ -17,6 +17,8 @@ wifi_la_LIBADD = @GDBUS_LIBS@
 bluetooth_la_SOURCES = bluetooth.c
 bluetooth_la_LIBADD = @GDBUS_LIBS@
 
+hso_la_SOURCES = hso.c
+
 udhcp_la_SOURCES = udhcp.c
 udhcp_la_CFLAGS = @GLIB_CFLAGS@ -DUDHCPC=\"@udh...@\"
 
@@ -26,8 +28,6 @@ dhclient_la_CFLAGS = @GLIB_CFLAGS@ @GDBUS_CFLAGS@ 
-DDHCLIENT=\"@dhcli...@\" \
 
 ipv4_la_SOURCES = ipv4.c
 
-rtnllink_la_SOURCES = rtnllink.c inet.h inet.c
-
 dnsproxy_la_SOURCES = dnsproxy.c
 
 resolvconf_la_SOURCES = resolvconf.c
diff --git a/plugins/hso.c b/plugins/hso.c
new file mode 100644
index 0000000..f42900f
--- /dev/null
+++ b/plugins/hso.c
@@ -0,0 +1,60 @@
+/*
+ *
+ *  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 <connman/plugin.h>
+#include <connman/device.h>
+#include <connman/log.h>
+
+static int hso_probe(struct connman_device *device)
+{
+       DBG("device %p", device);
+
+       return 0;
+}
+
+static void hso_remove(struct connman_device *device)
+{
+       DBG("device %p", device);
+}
+
+static struct connman_device_driver hso_driver = {
+       .name           = "hso",
+       .type           = CONNMAN_DEVICE_TYPE_HSO,
+       .probe          = hso_probe,
+       .remove         = hso_remove,
+};
+
+static int hso_init(void)
+{
+       return connman_device_driver_register(&hso_driver);
+}
+
+static void hso_exit(void)
+{
+       connman_device_driver_unregister(&hso_driver);
+}
+
+CONNMAN_PLUGIN_DEFINE(hso, "Option HSO device plugin", VERSION,
+                                               hso_init, hso_exit)
diff --git a/plugins/rtnllink.c b/plugins/rtnllink.c
deleted file mode 100644
index 8ac0715..0000000
--- a/plugins/rtnllink.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- *
- *  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 <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <linux/if_arp.h>
-#include <linux/wireless.h>
-
-#include <connman/plugin.h>
-#include <connman/device.h>
-#include <connman/rtnl.h>
-#include <connman/log.h>
-
-#include "inet.h"
-
-static GSList *device_list = NULL;
-
-static struct connman_device *find_device(int index)
-{
-       GSList *list;
-
-       for (list = device_list; list; list = list->next) {
-               struct connman_device *device = list->data;
-
-               if (connman_device_get_index(device) == index)
-                       return device;
-       }
-
-       return NULL;
-}
-
-static void rtnllink_newlink(unsigned short type, int index,
-                                       unsigned flags, unsigned change)
-{
-       enum connman_device_type devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;
-       struct connman_device *device;
-       gchar *name, *devname;
-
-       DBG("index %d", index);
-
-       device = find_device(index);
-       if (device != NULL)
-               return;
-
-       devname = inet_index2name(index);
-
-       if (type == ARPHRD_ETHER) {
-               char bridge_path[PATH_MAX], wimax_path[PATH_MAX];
-               struct stat st;
-               struct iwreq iwr;
-               int sk;
-
-               snprintf(bridge_path, PATH_MAX,
-                                       "/sys/class/net/%s/bridge", devname);
-               snprintf(wimax_path, PATH_MAX,
-                                       "/sys/class/net/%s/wimax", devname);
-
-               memset(&iwr, 0, sizeof(iwr));
-               strncpy(iwr.ifr_ifrn.ifrn_name, devname, IFNAMSIZ);
-
-               sk = socket(PF_INET, SOCK_DGRAM, 0);
-
-               if (g_str_has_prefix(devname, "bnep") == TRUE)
-                       devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;
-               else if (stat(bridge_path, &st) == 0 && (st.st_mode & S_IFDIR))
-                       devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;
-               else if (stat(wimax_path, &st) == 0 && (st.st_mode & S_IFDIR))
-                       devtype = CONNMAN_DEVICE_TYPE_WIMAX;
-               else if (ioctl(sk, SIOCGIWNAME, &iwr) == 0)
-                       devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;
-               else
-                       devtype = CONNMAN_DEVICE_TYPE_ETHERNET;
-
-               close(sk);
-       }
-
-       if (devtype == CONNMAN_DEVICE_TYPE_UNKNOWN) {
-               g_free(devname);
-               return;
-       }
-
-       name = inet_index2ident(index, "dev_");
-
-       device = connman_device_create(name, devtype);
-       if (device == NULL) {
-               g_free(devname);
-               g_free(name);
-               return;
-       }
-
-       connman_device_set_index(device, index);
-       connman_device_set_interface(device, devname);
-
-       g_free(devname);
-       g_free(name);
-
-       if (connman_device_register(device) < 0) {
-               connman_device_unref(device);
-               return;
-       }
-
-       device_list = g_slist_append(device_list, device);
-}
-
-static void rtnllink_dellink(unsigned short type, int index,
-                                       unsigned flags, unsigned change)
-{
-       struct connman_device *device;
-
-       DBG("index %d", index);
-
-       device = find_device(index);
-       if (device == NULL)
-               return;
-
-       device_list = g_slist_remove(device_list, device);
-
-       connman_device_unregister(device);
-       connman_device_unref(device);
-}
-
-static struct connman_rtnl rtnllink_rtnl = {
-       .name           = "rtnllink",
-       .newlink        = rtnllink_newlink,
-       .dellink        = rtnllink_dellink,
-};
-
-static int rtnllink_init(void)
-{
-       int err;
-
-       err = connman_rtnl_register(&rtnllink_rtnl);
-       if (err < 0)
-               return err;
-
-       connman_rtnl_send_getlink();
-
-       return 0;
-}
-
-static void rtnllink_exit(void)
-{
-       GSList *list;
-
-       connman_rtnl_unregister(&rtnllink_rtnl);
-
-       for (list = device_list; list; list = list->next) {
-               struct connman_device *device = list->data;
-
-               connman_device_unregister(device);
-               connman_device_unref(device);
-       }
-
-       g_slist_free(device_list);
-       device_list = NULL;
-}
-
-CONNMAN_PLUGIN_DEFINE(rtnllink, "RTNL link detection plugin", VERSION,
-                                               rtnllink_init, rtnllink_exit)
diff --git a/src/Makefile.am b/src/Makefile.am
index 018fb15..42a8a48 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,8 +6,9 @@ dbus_DATA = connman.conf
 sbin_PROGRAMS = connmand
 
 connmand_SOURCES = main.c connman.h log.c selftest.c error.c plugin.c \
-                       profile.c element.c device.c network.c security.c \
-                       resolver.c storage.c manager.c agent.c rtnl.c dbus.c
+                               profile.c element.c device.c network.c \
+                               security.c resolver.c storage.c manager.c \
+                               agent.c detect.c rtnl.c dbus.c
 
 if UDEV
 connmand_SOURCES += udev.c
diff --git a/src/connman.h b/src/connman.h
index 44ff954..55f78c0 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -85,6 +85,7 @@ void __connman_driver_rescan(struct connman_driver *driver);
 
 int __connman_element_init(DBusConnection *conn, const char *device);
 void __connman_element_start(void);
+void __connman_element_stop(void);
 void __connman_element_cleanup(void);
 
 void __connman_element_list(struct connman_element *element,
@@ -110,6 +111,9 @@ static inline void __connman_element_unlock(struct 
connman_element *element)
 {
 }
 
+int __connman_detect_init(void);
+void __connman_detect_cleanup(void);
+
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to