tethering: Check for kernel bridge support
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 10 Feb 2011 16:13:46 +0000 (17:13 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 10 Feb 2011 16:13:46 +0000 (17:13 +0100)
src/technology.c
src/tethering.c

index a5366dc..2a48698 100644 (file)
@@ -388,6 +388,8 @@ static DBusMessage *set_property(DBusConnection *conn,
                        return __connman_error_in_progress(msg);
 
                bridge = __connman_tethering_get_bridge();
+               if (bridge == NULL)
+                       return __connman_error_not_supported(msg);
 
                err = set_tethering(technology, bridge, tethering);
                if (err < 0)
index 2609ab0..705f5ee 100644 (file)
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/ioctl.h>
@@ -33,6 +35,8 @@
 
 #include <gdhcp/gdhcp.h>
 
+#define BRIDGE_SYSFS_DIR "/sys/module/bridge"
+
 #define BRIDGE_NAME "tether"
 #define BRIDGE_IP "192.168.218.1"
 #define BRIDGE_BCAST "192.168.218.255"
@@ -47,6 +51,13 @@ static GDHCPServer *tethering_dhcp_server = NULL;
 
 const char *__connman_tethering_get_bridge(void)
 {
+       struct stat st;
+
+       if (stat(BRIDGE_SYSFS_DIR, &st) < 0) {
+               connman_error("Missing support for 802.1d ethernet bridging");
+               return NULL;
+       }
+
        return BRIDGE_NAME;
 }