5 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <dbus/dbus.h>
32 #define UDHCPC_INTF "net.busybox.udhcpc"
33 #define UDHCPC_PATH "/net/busybox/udhcpc"
35 int main(int argc, char *argv[])
40 char *busname, *interface, *address, *netmask, *broadcast;
46 if (strcmp(argv[1], "bound") != 0 && strcmp(argv[1], "renew") != 0)
49 busname = "org.moblin.connman";
51 interface = getenv("interface");
53 address = getenv("ip");
54 netmask = getenv("subnet");
55 broadcast = getenv("broadcast");
56 gateway = getenv("router");
59 dbus_error_init(&error);
61 conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
63 if (dbus_error_is_set(&error) == TRUE) {
64 fprintf(stderr, "%s\n", error.message);
65 dbus_error_free(&error);
67 fprintf(stderr, "Failed to get on system bus\n");
71 msg = dbus_message_new_method_call(busname, UDHCPC_PATH,
72 UDHCPC_INTF, argv[1]);
74 dbus_connection_unref(conn);
75 fprintf(stderr, "Failed to allocate method call\n");
79 dbus_message_set_no_reply(msg, TRUE);
81 dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface,
82 DBUS_TYPE_STRING, &address,
83 DBUS_TYPE_STRING, &netmask,
84 DBUS_TYPE_STRING, &broadcast,
85 DBUS_TYPE_STRING, &gateway,
86 DBUS_TYPE_STRING, &dns,
89 if (dbus_connection_send(conn, msg, NULL) == FALSE)
90 fprintf(stderr, "Failed to send message\n");
92 dbus_message_unref(msg);
94 dbus_connection_unref(conn);