5 * Copyright (C) 2007-2009 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");
57 netmask = getenv("subnet");
61 broadcast = getenv("broadcast");
62 if (broadcast == NULL)
65 gateway = getenv("router");
73 dbus_error_init(&error);
75 conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
77 if (dbus_error_is_set(&error) == TRUE) {
78 fprintf(stderr, "%s\n", error.message);
79 dbus_error_free(&error);
81 fprintf(stderr, "Failed to get on system bus\n");
85 msg = dbus_message_new_method_call(busname, UDHCPC_PATH,
86 UDHCPC_INTF, argv[1]);
88 dbus_connection_unref(conn);
89 fprintf(stderr, "Failed to allocate method call\n");
93 dbus_message_set_no_reply(msg, TRUE);
95 dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface,
96 DBUS_TYPE_STRING, &address,
97 DBUS_TYPE_STRING, &netmask,
98 DBUS_TYPE_STRING, &broadcast,
99 DBUS_TYPE_STRING, &gateway,
100 DBUS_TYPE_STRING, &dns,
103 if (dbus_connection_send(conn, msg, NULL) == FALSE)
104 fprintf(stderr, "Failed to send message\n");
106 dbus_connection_flush(conn);
108 dbus_message_unref(msg);
110 dbus_connection_unref(conn);