diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-29 21:49:17 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-29 21:49:17 +0000 |
commit | 778fb0ca85a18c20a60cbd44c8786d60efe4d297 (patch) | |
tree | 5584329701619c82327d16dcdd9911727f6fbcbf /network/server.c | |
parent | 3b82e98cb01ce9632701c0872e5e64f1290a0c8a (diff) |
network: Added bridge add interface function
Diffstat (limited to 'network/server.c')
-rw-r--r-- | network/server.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/network/server.c b/network/server.c index 1e1bede0..5ae7c634 100644 --- a/network/server.c +++ b/network/server.c @@ -47,6 +47,7 @@ #define NETWORK_SERVER_INTERFACE "org.bluez.network.Server" +#include "bridge.h" #include "common.h" #include "server.h" @@ -264,6 +265,8 @@ static void authorization_callback(DBusPendingCall *pcall, void *data) return; } + sk = g_io_channel_unix_get_fd(ns->pauth->io); + dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("Access denied: %s", derr.message); @@ -279,8 +282,6 @@ static void authorization_callback(DBusPendingCall *pcall, void *data) memset(devname, 0, 16); strncpy(devname, netdev, 16); - /* FIXME: Is it the correct order? */ - sk = g_io_channel_unix_get_fd(ns->pauth->io); if (bnep_connadd(sk, ns->id, devname) < 0) { response = BNEP_CONN_NOT_ALLOWED; goto failed; @@ -289,6 +290,13 @@ static void authorization_callback(DBusPendingCall *pcall, void *data) info("Authorization succedded. New connection: %s", devname); response = BNEP_SUCCESS; + if (bridge_add_interface("pan0", devname) < 0) { + error("Can't add %s to the bridge: %s(%d)", + devname, strerror(errno), errno); + response = BNEP_CONN_NOT_ALLOWED; + goto failed; + } + /* FIXME: Enable routing if applied */ /* FIXME: send the D-Bus message to notify the new bnep iface */ @@ -299,6 +307,8 @@ failed: pending_auth_free(ns->pauth); ns->pauth = NULL; + close(sk); + dbus_message_unref(reply); dbus_pending_call_unref(pcall); } @@ -678,8 +688,6 @@ static DBusHandlerResult enable(DBusConnection *conn, return err_failed(conn, msg, "Unable to register the service record"); } - /* FIXME: Check security */ - err = l2cap_listen(ns); if (err < 0) return err_failed(conn, msg, strerror(-err)); |