Make sure to disconnect network on removal
[connman] / scripts / udhcpc-script.c
index c7a7ae2..b5f9c54 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2009  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
@@ -29,8 +29,8 @@
 
 #include <dbus/dbus.h>
 
-#define UDHCPC_INTF  "org.busybox.udhcpc"
-#define UDHCPC_PATH  "/org/busybox/udhcpc"
+#define UDHCPC_INTF  "net.busybox.udhcpc"
+#define UDHCPC_PATH  "/net/busybox/udhcpc"
 
 int main(int argc, char *argv[])
 {
@@ -51,10 +51,24 @@ int main(int argc, char *argv[])
        interface = getenv("interface");
 
        address = getenv("ip");
+       if (address == NULL)
+               address = "";
+
        netmask = getenv("subnet");
+       if (netmask == NULL)
+               netmask = "";
+
        broadcast = getenv("broadcast");
+       if (broadcast == NULL)
+               broadcast = "";
+
        gateway = getenv("router");
+       if (gateway == NULL)
+               gateway = "";
+
        dns = getenv("dns");
+       if (dns == NULL)
+               dns = "";
 
        dbus_error_init(&error);
 
@@ -89,6 +103,8 @@ int main(int argc, char *argv[])
        if (dbus_connection_send(conn, msg, NULL) == FALSE)
                fprintf(stderr, "Failed to send message\n");
 
+       dbus_connection_flush(conn);
+
        dbus_message_unref(msg);
 
        dbus_connection_unref(conn);