summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
Diffstat (limited to 'network')
-rw-r--r--network/bridge.c17
-rw-r--r--network/bridge.h1
-rw-r--r--network/server.c16
3 files changed, 30 insertions, 4 deletions
diff --git a/network/bridge.c b/network/bridge.c
index 76c2a507..a6930194 100644
--- a/network/bridge.c
+++ b/network/bridge.c
@@ -74,3 +74,20 @@ int bridge_remove(const char *name)
return 0;
}
+
+int bridge_add_interface(const char *bridge, const char *dev)
+{
+ struct ifreq ifr;
+ int ifindex = if_nametoindex(dev);
+
+ if (ifindex == 0)
+ return -ENODEV;
+
+ strncpy(ifr.ifr_name, bridge, IFNAMSIZ);
+ ifr.ifr_ifindex = ifindex;
+
+ if (ioctl(bridge_socket, SIOCBRADDIF, &ifr) < 0)
+ return -errno;
+
+ return 0;
+}
diff --git a/network/bridge.h b/network/bridge.h
index 45e744d3..2630b892 100644
--- a/network/bridge.h
+++ b/network/bridge.h
@@ -26,3 +26,4 @@ void bridge_cleanup(void);
int bridge_create(const char *name);
int bridge_remove(const char *name);
+int bridge_add_interface(const char *bridge, const char *dev);
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));