diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-05-14 12:28:55 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-05-14 12:28:55 +0000 |
commit | 57704487a484a6d599f12cee65b63f8daa7ecf8b (patch) | |
tree | b71512e03576db402100b5af5761c3c0f68c079c /network/connection.c | |
parent | 772f25e26e1d1c5982855eefd59b51c7e4aaab95 (diff) |
Add method to retrieve adapter address
Diffstat (limited to 'network/connection.c')
-rw-r--r-- | network/connection.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/network/connection.c b/network/connection.c index d565fea2..9062c419 100644 --- a/network/connection.c +++ b/network/connection.c @@ -313,15 +313,36 @@ static int l2cap_connect(struct network_conn *nc) return 0; } +static DBusHandlerResult get_adapter(DBusConnection *conn, DBusMessage *msg, + void *data) +{ + struct network_conn *nc = data; + DBusMessage *reply; + char addr[18]; + const char *paddr = addr; + + ba2str(&nc->src, addr); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + dbus_message_append_args(reply, DBUS_TYPE_STRING, &paddr, + DBUS_TYPE_INVALID); + + return send_message_and_unref(conn, reply); +} + static DBusHandlerResult get_address(DBusConnection *conn, DBusMessage *msg, void *data) { struct network_conn *nc = data; DBusMessage *reply; - char raddr[18]; - const char *paddr = raddr; + char addr[18]; + const char *paddr = addr; + + ba2str(&nc->dst, addr); - ba2str(&nc->dst, raddr); reply = dbus_message_new_method_return(msg); if (!reply) return DBUS_HANDLER_RESULT_NEED_MEMORY; @@ -570,6 +591,7 @@ static void connection_unregister(DBusConnection *conn, void *data) } static DBusMethodVTable connection_methods[] = { + { "GetAdapter", get_adapter, "", "s" }, { "GetAddress", get_address, "", "s" }, { "GetUUID", get_uuid, "", "s" }, { "GetName", get_name, "", "s" }, @@ -698,4 +720,3 @@ gboolean connection_has_pending(DBusConnection *conn, const char *path) return (nc->state == CONNECTING); } - |