summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-03-24 12:33:56 (GMT)
committerMarcel Holtmann <marcel@holtmann.org>2008-03-24 12:33:56 (GMT)
commitdc405c55dc7e4a4cc2533e8103adac7340d6d8de (patch)
tree5e9f350655dbeea6dc9fce7b8a4e5ae84a09d3d0 /scripts
parent22d523336fe891bd57af03e919d8fc59be4b2609 (diff)
downloadconnman-dc405c55dc7e4a4cc2533e8103adac7340d6d8de.zip
connman-dc405c55dc7e4a4cc2533e8103adac7340d6d8de.tar.gz
connman-dc405c55dc7e4a4cc2533e8103adac7340d6d8de.tar.bz2
Update DHCP plugin to use D-Bus low-level calls
Diffstat (limited to 'scripts')
-rw-r--r--scripts/dhclient-script.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/scripts/dhclient-script.c b/scripts/dhclient-script.c
index 39b235c..f4a8431 100644
--- a/scripts/dhclient-script.c
+++ b/scripts/dhclient-script.c
@@ -56,6 +56,7 @@ static void append(DBusMessageIter *dict, const char *pattern)
int main(int argc, char *argv[])
{
DBusConnection *conn;
+ DBusError error;
DBusMessage *msg;
DBusMessageIter iter, dict;
dbus_uint32_t pid;
@@ -67,17 +68,28 @@ int main(int argc, char *argv[])
reason = getenv("reason");
interface = getenv("interface");
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
- if (conn == NULL)
- exit(1);
+ dbus_error_init(&error);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (conn == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ fprintf(stderr, "%s\n", error.message);
+ dbus_error_free(&error);
+ } else
+ fprintf(stderr, "Failed to get on system bus\n");
+ return 0;
+ }
msg = dbus_message_new_method_call(busname, "/org/isc/dhclient",
"org.isc.dhclient", "notify");
if (msg == NULL) {
dbus_connection_unref(conn);
- exit(1);
+ fprintf(stderr, "Failed to allocate method call\n");
+ return 0;
}
+ dbus_message_set_no_reply(msg, TRUE);
+
dbus_message_append_args(msg, DBUS_TYPE_UINT32, &pid,
DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID);
@@ -100,7 +112,8 @@ int main(int argc, char *argv[])
dbus_message_iter_close_container(&iter, &dict);
- dbus_connection_send(conn, msg, NULL);
+ if (dbus_connection_send(conn, msg, NULL) == FALSE)
+ fprintf(stderr, "Failed to send message\n");
dbus_message_unref(msg);