include/storage.h include/service.h \
include/resolver.h include/ipconfig.h \
include/device.h include/network.h include/inet.h \
- include/ondemand.h
+ include/ondemand.h include/tethering.h
nodist_include_HEADERS = include/version.h
--- /dev/null
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __CONNMAN_TETHERING_H
+#define __CONNMAN_TETHERING_H
+
+void connman_tethering_enabled(void);
+void connman_tethering_disabled(void);
+
+#endif
#include <connman/technology.h>
#include <connman/device.h>
#include <connman/inet.h>
+#include <connman/tethering.h>
#include <connman/dbus.h>
#include <connman/log.h>
dbus_message_unref(reply);
dbus_pending_call_unref(call);
+ connman_tethering_enabled();
}
+static void server_unregister_reply(DBusPendingCall *call, void *user_data)
+{
+ DBusError error;
+ DBusMessage *reply;
+
+ DBG("");
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&error);
+
+ if (dbus_set_error_from_message(&error, reply) == TRUE) {
+ connman_error("%s", error.message);
+ dbus_error_free(&error);
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+ return;
+ }
+
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+
+ connman_tethering_disabled();
+}
+
+
static void server_register(const char *path, const char *uuid,
const char *bridge, connman_bool_t enabled)
{
return;
}
- dbus_pending_call_set_notify(call, server_register_reply,
- g_strdup(path), g_free);
+ if (enabled == TRUE)
+ dbus_pending_call_set_notify(call, server_register_reply,
+ NULL, NULL);
+ else
+ dbus_pending_call_set_notify(call, server_unregister_reply,
+ NULL, NULL);
dbus_message_unref(message);
}
const char *bridge = user_data;
const char *path;
+ DBG("");
+
path = connman_device_get_string(device, "Path");
server_register(path, "nap", bridge, TRUE);
const char *bridge = user_data;
const char *path;
+ DBG("");
+
path = connman_device_get_string(device, "Path");
server_register(path, "nap", bridge, FALSE);
#include "connman.h"
+#include <connman/tethering.h>
+
#define BRIDGE_NAME "tether"
static connman_bool_t tethering_status = FALSE;
+gint tethering_enabled;
connman_bool_t __connman_tethering_get_status(void)
{
return 0;
}
+void connman_tethering_enabled(void)
+{
+ if (tethering_status == FALSE)
+ return;
+
+ DBG("enabled %d", tethering_enabled + 1);
+
+ if (g_atomic_int_exchange_and_add(&tethering_enabled, 1) == 0) {
+ /* TODO Start DHCP server and DNS proxy on the bridge */
+ DBG("tethering started");
+ }
+}
+
+void connman_tethering_disabled(void)
+{
+ if (tethering_status == FALSE)
+ return;
+
+ DBG("enabled %d", tethering_enabled - 1);
+
+ if (g_atomic_int_dec_and_test(&tethering_enabled) == 0) {
+ /* TODO Stop DHCP server and DNS proxy on the bridge */
+ DBG("tethering stopped");
+ }
+}
+
int __connman_tethering_set_status(connman_bool_t status)
{
if (status == tethering_status)
{
DBG("");
+ tethering_enabled = 0;
+
return 0;
}