This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 plugins/Makefile.am |    2 +-
 plugins/bluetooth.c |    1 +
 plugins/ethernet.c  |   92 ++------------------------------------------------
 plugins/inet.c      |   82 +++++++++++++++++++++++++++++++++++++++++++++
 plugins/inet.h      |    3 ++
 5 files changed, 91 insertions(+), 89 deletions(-)

New commits:
commit b972ec96236afc662b21ace09d6adaa29d222411
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 03:30:12 2008 +0100

    Use helpers for ifup and ifdown

commit 1c74d1d740d16d2ede335693052b52342717b5d8
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 03:29:31 2008 +0100

    Add helpers for ifup and ifdown

commit 6877247bb62d3492570a4ee4c134f495cb680e92
Author: Marcel Holtmann <[email protected]>
Date:   Sun Dec 28 03:14:53 2008 +0100

    Use manual policy as default


Diff in this email is a maximum of 400 lines.
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 09ca6f7..b71e6b9 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -9,7 +9,7 @@ loopback_la_SOURCES = loopback.c
 
 netdev_la_SOURCES = netdev.c
 
-ethernet_la_SOURCES = ethernet.c
+ethernet_la_SOURCES = ethernet.c inet.h inet.c
 
 wifi_la_SOURCES = wifi.c inet.h inet.c supplicant.h supplicant.c
 wifi_la_LIBADD = @GDBUS_LIBS@
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 46f8f42..8993ca6 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -421,6 +421,7 @@ static void adapter_properties(DBusConnection *connection, 
const char *path,
 
        connman_device_set_interface(adapter, node);
 
+       connman_device_set_policy(adapter, CONNMAN_DEVICE_POLICY_MANUAL);
        connman_device_set_mode(adapter, CONNMAN_DEVICE_MODE_MULTIPLE_NETWORKS);
 
        if (connman_device_register(adapter) < 0) {
diff --git a/plugins/ethernet.c b/plugins/ethernet.c
index 08cfb4f..5ddc765 100644
--- a/plugins/ethernet.c
+++ b/plugins/ethernet.c
@@ -36,6 +36,8 @@
 #include <connman/rtnl.h>
 #include <connman/log.h>
 
+#include "inet.h"
+
 struct ethernet_data {
        int index;
        unsigned flags;
@@ -90,92 +92,6 @@ static struct connman_rtnl ethernet_rtnl = {
        .newlink        = ethernet_newlink,
 };
 
-static int iface_up(struct ethernet_data *ethernet)
-{
-       struct ifreq ifr;
-       int sk, err;
-
-       DBG("index %d flags %d", ethernet->index, ethernet->flags);
-
-       sk = socket(PF_INET, SOCK_DGRAM, 0);
-       if (sk < 0)
-               return -errno;
-
-       memset(&ifr, 0, sizeof(ifr));
-       ifr.ifr_ifindex = ethernet->index;
-
-       if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
-               err = -errno;
-               goto done;
-       }
-
-       if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
-               err = -errno;
-               goto done;
-       }
-
-       if (ifr.ifr_flags & IFF_UP) {
-               err = -EALREADY;
-               goto done;
-       }
-
-       ifr.ifr_flags |= IFF_UP;
-
-       if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0) {
-               err = -errno;
-               goto done;
-       }
-
-       err = 0;
-
-done:
-       close(sk);
-
-       return err;
-}
-
-static int iface_down(struct ethernet_data *ethernet)
-{
-       struct ifreq ifr;
-       int sk, err;
-
-       DBG("index %d flags %d", ethernet->index, ethernet->flags);
-
-       sk = socket(PF_INET, SOCK_DGRAM, 0);
-       if (sk < 0)
-               return -errno;
-
-       memset(&ifr, 0, sizeof(ifr));
-       ifr.ifr_ifindex = ethernet->index;
-
-       if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
-               err = -errno;
-               goto done;
-       }
-
-       if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
-               err = -errno;
-               goto done;
-       }
-
-       if (!(ifr.ifr_flags & IFF_UP)) {
-               err = -EALREADY;
-               goto done;
-       }
-
-       ifr.ifr_flags &= ~IFF_UP;
-
-       if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0)
-               err = -errno;
-       else
-               err = 0;
-
-done:
-       close(sk);
-
-       return err;
-}
-
 static int ethernet_probe(struct connman_device *device)
 {
        struct ethernet_data *ethernet;
@@ -216,7 +132,7 @@ static int ethernet_enable(struct connman_device *device)
 
        DBG("device %p", device);
 
-       return iface_up(ethernet);
+       return inet_ifup(ethernet->index);
 }
 
 static int ethernet_disable(struct connman_device *device)
@@ -225,7 +141,7 @@ static int ethernet_disable(struct connman_device *device)
 
        DBG("device %p", device);
 
-       return iface_down(ethernet);
+       return inet_ifdown(ethernet->index);
 }
 
 static struct connman_device_driver ethernet_driver = {
diff --git a/plugins/inet.c b/plugins/inet.c
index ab0fcdc..e3fedfb 100644
--- a/plugins/inet.c
+++ b/plugins/inet.c
@@ -105,3 +105,85 @@ char *inet_index2ident(int index, const char *prefix)
 
        return str;
 }
+
+int inet_ifup(int index)
+{
+       struct ifreq ifr;
+       int sk, err;
+
+       sk = socket(PF_INET, SOCK_DGRAM, 0);
+       if (sk < 0)
+               return -errno;
+
+       memset(&ifr, 0, sizeof(ifr));
+       ifr.ifr_ifindex = index;
+
+       if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
+               err = -errno;
+               goto done;
+       }
+
+       if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
+               err = -errno;
+               goto done;
+       }
+
+       if (ifr.ifr_flags & IFF_UP) {
+               err = -EALREADY;
+               goto done;
+       }
+
+       ifr.ifr_flags |= IFF_UP;
+
+       if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0) {
+               err = -errno;
+               goto done;
+       }
+
+       err = 0;
+
+done:
+       close(sk);
+
+       return err;
+}
+
+int inet_ifdown(int index)
+{
+       struct ifreq ifr;
+       int sk, err;
+
+       sk = socket(PF_INET, SOCK_DGRAM, 0);
+       if (sk < 0)
+               return -errno;
+
+       memset(&ifr, 0, sizeof(ifr));
+       ifr.ifr_ifindex = index;
+
+       if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
+               err = -errno;
+               goto done;
+       }
+
+       if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
+               err = -errno;
+               goto done;
+       }
+
+       if (!(ifr.ifr_flags & IFF_UP)) {
+               err = -EALREADY;
+               goto done;
+       }
+
+       ifr.ifr_flags &= ~IFF_UP;
+
+       if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0)
+               err = -errno;
+       else
+               err = 0;
+
+done:
+       close(sk);
+
+       return err;
+}
diff --git a/plugins/inet.h b/plugins/inet.h
index afa8025..3246cc1 100644
--- a/plugins/inet.h
+++ b/plugins/inet.h
@@ -21,3 +21,6 @@
 
 char *inet_index2name(int index);
 char *inet_index2ident(int index, const char *prefix);
+
+int inet_ifup(int index);
+int inet_ifdown(int index);
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to