Use start/stop callbacks if provided
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 11 Mar 2008 13:54:48 +0000 (14:54 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 11 Mar 2008 13:54:48 +0000 (14:54 +0100)
src/iface-inet.c
src/iface.c

index a0915af..927f568 100644 (file)
@@ -145,10 +145,7 @@ int __connman_iface_up(struct connman_iface *iface)
                goto done;
        }
 
-       if (iface->driver->start)
-               err = iface->driver->start(iface);
-       else
-               err = 0;
+       err = 0;
 
 done:
        close(sk);
@@ -163,12 +160,6 @@ int __connman_iface_down(struct connman_iface *iface)
 
        DBG("iface %p", iface);
 
-       if (iface->driver->stop) {
-               err = iface->driver->stop(iface);
-               if (err < 0)
-                       return err;
-       }
-
        sk = socket(PF_INET, SOCK_DGRAM, 0);
        if (sk < 0)
                return -errno;
index b91c197..65e4cdd 100644 (file)
@@ -215,14 +215,20 @@ static void switch_policy(struct connman_iface *iface)
                iface->state = CONNMAN_IFACE_STATE_SHUTDOWN;
                state_changed(iface);
                connman_iface_clear_ipv4(iface);
-               __connman_iface_down(iface);
+               if (iface->driver->stop)
+                       iface->driver->stop(iface);
+               else
+                       __connman_iface_down(iface);
                break;
 
        case CONNMAN_IFACE_POLICY_IGNORE:
                break;
 
        case CONNMAN_IFACE_POLICY_AUTO:
-               __connman_iface_up(iface);
+               if (iface->driver->start)
+                       iface->driver->start(iface);
+               else
+                       __connman_iface_up(iface);
                state_changed(iface);
                break;
 
@@ -252,9 +258,13 @@ void connman_iface_indicate_disabled(struct connman_iface *iface)
 
        if (iface->policy == CONNMAN_IFACE_POLICY_AUTO) {
                iface->state = CONNMAN_IFACE_STATE_ENABLED;
-               __connman_iface_up(iface);
+               if (iface->driver->start)
+                       iface->driver->start(iface);
+               else
+                       __connman_iface_up(iface);
        } else
                iface->state = CONNMAN_IFACE_STATE_SHUTDOWN;
+
        state_changed(iface);
 }