From: Claudio Takahasi <cktakahasi@gmail.com>
To: bluez-devel@lists.sourceforge.net, cktakahasi@gmail.com
Subject: [Bluez-devel] Re: bluetoothd specification
Date: Fri, 15 Jul 2005 14:37:37 -0300 [thread overview]
Message-ID: <e1effdeb050715103731d599d7@mail.gmail.com> (raw)
In-Reply-To: <e1effdeb05071213476bbc0fa0@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2401 bytes --]
Hi Marcel,
I am sending a suggestion for bluetoothd implementation.
Please send your feedback.
Regarding the d-bus version checking, there is a different
approach using pkg-config for check dbus version instead of
verify if a function belongs to the dbus-1
The next step is implement the main loop.
Regards,
Claudio.
On 7/12/05, Claudio Takahasi <cktakahasi@gmail.com> wrote:
> Hi Marcel,
>
> Periodic inquiry and adapter setup is extremely
> necessary for me. Is it possible set a high priority
> for these features?
>
> Regarding the interfaces and objects path of the
> bluetoothd my suggestion is:
>
> >>>bluetoothd
> DBus service : org.bluez.hci
> DBus interface: org.bluez.hci
> DBus object path: org/bluez/hci
> - setup link properties
> - setup inquiry mode
> - kill bluetoothd
> - show local adapters
> - ???
> >>>SDP
> DBus service : org.bluez.sdp
> DBus interface: org.bluez.sdp
> DBus object path: org/bluez/sdp
> methods:
> - search
> - register/unregister
> - get local services
> - ???
>
> >>>PAN
> DBus service : org.bluez.pan
> DBus interface: org.bluez.pan
> DBus object path: org/bluez/pan
> - connect/disconnect
> - listen start/stop
> - connections
>
>
> Open issues:
> - How/Where handle multiple bluetooth adapters?
> solution1: the device id (hci0) can be part of object path
> eg: org.bluez.hci0.pan org.bluez.hci0.sdp
>
> solution2: pass the device id as parameter or define a method
> to set the active adapter.
>
>
> I am not sure if it is better define a hierarchical objects or
> register multiples objects. Dbus support two functions:
> dbus_connection_register_object_path and
> dbus_connection_register_fallback(for a given subsection of the
> object hierarchy). But I think that it is not important now because
> for both approachs the message handler functions are distinct.
> I will investigate more which approach is the best.
>
> Defining an hierarchical approach make easier define policy/rules
> in the dbus configuration files.
>
> Do you have a different design for it or suggestions?
> There are a lot services that shall be inserted in the bluetoothd,
> maybe should be better define multiple interfaces(adapter, link, ... )
> for this daemon.
>
>
> Regards,
> Claudio.
>
[-- Attachment #2: bluetoothd-patch-00.01 --]
[-- Type: application/octet-stream, Size: 27775 bytes --]
--- bluez-utils-2.18.orig/acinclude.m4 2005-07-03 18:19:51.000000000 -0300
+++ bluetoothd-0.0.4/acinclude.m4 2005-07-15 14:17:57.418366064 -0300
@@ -255,6 +255,34 @@
AC_SUBST(DBUS_LIBS)
])
+AC_DEFUN([AC_VER_DBUS], [
+ if test "${dbus_found}" = "yes"; then
+ if test -z "$PKG_CONFIG"; then
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+ fi
+ if test "$PKG_CONFIG" = "no" ; then
+ echo "*** The pkg-config script could not be found. It is"
+ echo "*** required for check D-BUS version. Make sure it is"
+ echo "*** in your path, or set the PKG_CONFIG environment"
+ echo "*** variable to the full path to pkg-config."
+ else
+
+ AC_MSG_CHECKING([dbus version])
+
+ DBUS_VERSION=`$PKG_CONFIG --modversion dbus-1`
+ DBUS_MAJOR_VER=`echo $DBUS_VERSION | cut -d. -f 1`
+ DBUS_MINOR_VER=`echo $DBUS_VERSION | cut -d. -f 2`
+ DBUS_MICRO_VER=`echo $DBUS_VERSION | cut -d. -f 3`
+
+ AC_MSG_RESULT($DBUS_VERSION)
+ AC_DEFINE_UNQUOTED(DBUS_MAJOR_VER, $DBUS_MAJOR_VER, [D-BUS major version.])
+ AC_DEFINE_UNQUOTED(DBUS_MINOR_VER, $DBUS_MINOR_VER, [D-BUS minor version.])
+ AC_DEFINE_UNQUOTED(DBUS_MICRO_VER, $DBUS_MICRO_VER, [D-BUS micro version.])
+
+ fi
+ fi
+])
+
AC_DEFUN([AC_ARG_BLUEZ], [
debug_enable=no
pie_enable=no
--- bluez-utils-2.18.orig/config.h.in 2005-07-03 20:15:38.000000000 -0300
+++ bluetoothd-0.0.4/config.h.in 2005-07-15 14:17:57.417366216 -0300
@@ -15,6 +15,15 @@
/* Define to 1 if you have the dbus_pending_call_steal_reply() function. */
#undef HAVE_DBUS_PENDING_CALL_STEAL_REPLY
+/* D-BUS major version. */
+#undef DBUS_MAJOR_VER
+
+/* D-BUS minor version. */
+#undef DBUS_MINOR_VER
+
+/* D-BUS micro version. */
+#undef DBUS_MICRO_VER
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
--- bluez-utils-2.18.orig/configure.in 2005-07-03 20:12:08.000000000 -0300
+++ bluetoothd-0.0.4/configure.in 2005-07-15 14:17:57.416366368 -0300
@@ -31,7 +31,8 @@
AC_PATH_ALSA
AC_PATH_USB
AC_PATH_DBUS
+AC_VER_DBUS
AC_ARG_BLUEZ
-AC_OUTPUT(Makefile common/Makefile tools/Makefile rfcomm/Makefile hcid/Makefile sdpd/Makefile dund/Makefile pand/Makefile hidd/Makefile cups/Makefile alsa/Makefile test/Makefile scripts/Makefile pcmcia/Makefile extra/Makefile)
+AC_OUTPUT(Makefile common/Makefile daemon/Makefile tools/Makefile rfcomm/Makefile hcid/Makefile sdpd/Makefile dund/Makefile pand/Makefile hidd/Makefile cups/Makefile alsa/Makefile test/Makefile scripts/Makefile pcmcia/Makefile extra/Makefile)
diff -urNaw bluez-utils-2.18.orig/daemon/bluetoothd_dbus.c bluetoothd-0.0.4/daemon/bluetoothd_dbus.c
--- bluez-utils-2.18.orig/daemon/bluetoothd_dbus.c 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/bluetoothd_dbus.c 2005-07-15 14:17:57.111412728 -0300
@@ -0,0 +1,316 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+
+#include "bluetoothd_internal.h"
+#include "pan_dbus.h"
+
+
+typedef struct {
+ const char *profile;
+ int8_t status; /* 1:active 0:disabled*/
+ register_function_t *reg_func;
+ unregister_function_t *unreg_func;
+}__attribute__((packed))btd_fallback_entry_t;
+
+btd_fallback_entry_t btd_profiles [] = {
+ {PAN_DBUS_SERVICE, 1 , pan_dbus_register, pan_dbus_unregister},
+ /* dund */
+ /* sdp */
+ /* hid */
+ { NULL, 0, NULL , NULL }
+};
+
+
+typedef struct
+{
+ int8_t run;
+ DBusConnection* sys_bus;
+ DBusConnection* sess_bus;
+}__attribute__((packed)) bluetoothd_app_data_t;
+
+
+
+int8_t bluetoothd_disable_profile(const char *profile)
+{
+ int8_t ret = 0;
+ btd_fallback_entry_t *ptr = btd_profiles;
+ char service[128];
+
+ sprintf(service, "%s.%s",BLUETOOTHD_DBUS_SERVICE, profile);
+
+ for(;ptr->profile; ptr++) {
+ if(strcasecmp(ptr->profile, service) == 0 ) {
+ ptr->status = 0;
+ }
+ }
+
+ return ret;
+}
+int8_t bluetoothd_enable_profile(const char *profile)
+{
+ int8_t ret = 0;
+ btd_fallback_entry_t *ptr = btd_profiles;
+
+ char service[128];
+
+ sprintf(service, "%s.%s",BLUETOOTHD_DBUS_SERVICE, profile);
+
+
+ for(;ptr->profile; ptr++) {
+ if(strcasecmp(ptr->profile, service) == 0 ) {
+ ptr->status = 0;
+ }
+ }
+
+ return ret;
+}
+
+
+
+static DBusHandlerResult _btd_msg_func(DBusConnection *conn,
+ DBusMessage *msg, void *data);
+
+
+/**
+ * Virtual table that implements the handlers
+ * of the object path hierarchy
+ **/
+static DBusObjectPathVTable btd_vtable = {
+ NULL,
+ &_btd_msg_func,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+static bluetoothd_app_data_t app_data;
+
+
+static DBusMessage* handle_periodic_inq_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_scan_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_get_dev_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_list_services_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_exit_req(DBusMessage *msg, void *data);
+
+static service_table_t btd_services[] = {
+ {BLUETOOTHD_SVC_PERIODIC_INQ_REQ, handle_periodic_inq_req },
+ {BLUETOOTHD_SVC_SCAN_REQ, handle_scan_req },
+ {BLUETOOTHD_SVC_GET_DEVICES_REQ, handle_get_dev_req },
+ {BLUETOOTHD_SVC_LIST_SERVICES_REQ, handle_list_services_req },
+ {BLUETOOTHD_SVC_EXIT_REQ, handle_exit_req },
+ {NULL, NULL}
+};
+
+static DBusHandlerResult _btd_signal_filter (DBusConnection *conn, DBusMessage *msg, void *data)
+{
+ DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ const char *iface;
+ const char *method;
+
+ if(!msg || !conn)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ if (dbus_message_get_type (msg) != DBUS_MESSAGE_TYPE_SIGNAL)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ iface = dbus_message_get_interface(msg);
+ method = dbus_message_get_member(msg);
+
+ if(strcmp(iface, DBUS_INTERFACE_LOCAL) == 0) {
+ if(strcmp(method, "Disconnected") == 0){
+ //TODO
+ app_data.run = 0;
+ ret = DBUS_HANDLER_RESULT_HANDLED;
+ }
+ } else
+ if(strcmp(iface, DBUS_INTERFACE_DBUS) == 0) {
+ if(strcmp(method, "NameOwnerChanged") == 0) {
+ //TODO
+ ret = DBUS_HANDLER_RESULT_HANDLED;
+ }
+ if(strcmp(method, "NameAcquired") == 0) {
+ //TODO
+ ret = DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ }
+ return ret;
+}
+
+
+
+int8_t bluetoothd_init()
+{
+ btd_fallback_entry_t *ptr = btd_profiles;
+
+ DBusError dbus_error;
+ int8_t ret = 0;
+
+
+ memset(&app_data, 0, sizeof(bluetoothd_app_data_t));
+
+ dbus_error_init(&dbus_error);
+ app_data.sys_bus = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
+
+ if (!app_data.sys_bus) {
+ syslog(LOG_ERR, "D-Bus Error: %s", dbus_error.message);
+ dbus_error_free(&dbus_error);
+ ret = -1;
+ goto cleanup;
+ }
+
+#if 0
+ Disable for now
+ dbus_error_init(&dbus_error);
+ app_data.sess_bus = dbus_bus_get(DBUS_BUS_SESSION, &dbus_error);
+
+ if (!app_data.sess_bus) {
+ syslog(LOG_ERR, "D-Bus Error: %s", dbus_error.message);
+ dbus_error_free(&dbus_error);
+ ret = -1;
+ goto cleanup;
+ }
+#endif
+ dbus_error_init (&dbus_error);
+
+ DBUS_BUS_REQUEST_NAME(app_data.sys_bus, BLUETOOTHD_DBUS_SERVICE,
+ DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT,
+ &dbus_error);
+
+ if (dbus_error_is_set (&dbus_error)) {
+ syslog(LOG_ERR,"D-Bus Error: %s\n", dbus_error.message);
+ dbus_error_free (&dbus_error);
+ ret = -1;
+ goto cleanup;
+
+ }
+
+ if(!dbus_connection_register_object_path(app_data.sys_bus, BLUETOOTHD_DBUS_OBJ_PATH, &btd_vtable, NULL)) {
+ syslog(LOG_ERR,"DBUS failed to register %s object", BLUETOOTHD_DBUS_OBJ_PATH);
+ ret = -1;
+ goto cleanup;
+ }
+ //Register fallback D-Bus objects
+ while(ptr->profile)
+ {
+ if(ptr->status)
+ ptr->reg_func(app_data.sys_bus);
+ ptr++;
+ }
+
+
+ if (!dbus_connection_add_filter (app_data.sys_bus, _btd_signal_filter, NULL, NULL)) {
+ syslog(LOG_ERR,"DBUS failed to add filter");
+ ret = -1;
+ goto cleanup;
+ }
+
+ //TODO init main loop
+
+
+cleanup:
+ return ret;
+}
+
+int8_t bluetoothd_exit()
+{
+ int8_t ret = 0;
+ app_data.run = 0;
+ return ret;
+}
+
+static DBusHandlerResult _btd_msg_func(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ service_table_t *ptr_handlers = btd_services;
+ DBusMessage *reply = NULL;
+ DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ uint16_t type;
+ const char *iface;
+ const char *method;
+
+ type = dbus_message_get_type(msg);
+ iface = dbus_message_get_interface(msg);
+ method = dbus_message_get_member (msg);
+
+ if((type == DBUS_MESSAGE_TYPE_METHOD_CALL) &&
+ (strcmp(iface, BLUETOOTHD_DBUS_IFACE_REQ) == 0) &&
+ (method != NULL)){
+ for (;ptr_handlers->name; ptr_handlers++) {
+ if (strcmp(method, ptr_handlers->name) == 0) {
+ reply = (ptr_handlers->handler_func)(msg, data);
+ if (reply) {
+ if (!dbus_connection_send (conn, reply, NULL)) {
+ syslog(LOG_ERR, "%s line:%d Can't send reply message!",
+ __PRETTY_FUNCTION__, __LINE__) ;
+ }
+ dbus_message_unref (reply);
+ }
+ ret = DBUS_HANDLER_RESULT_HANDLED;
+ break;
+ }
+ }
+ }
+ return ret;
+
+}
+
+
+static DBusMessage* handle_periodic_inq_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
+static DBusMessage* handle_scan_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
+static DBusMessage* handle_get_dev_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
+static DBusMessage* handle_list_services_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
+
+static DBusMessage* handle_exit_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
diff -urNaw bluez-utils-2.18.orig/daemon/bluetoothd_dbus.h bluetoothd-0.0.4/daemon/bluetoothd_dbus.h
--- bluez-utils-2.18.orig/daemon/bluetoothd_dbus.h 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/bluetoothd_dbus.h 2005-07-15 14:17:57.113412424 -0300
@@ -0,0 +1,34 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef __H_BLUETOOTHD_DBUS_H__
+#define __H_BLUETOOTHD_DBUS_H__
+
+#include "bluetoothd_internal.h"
+
+int8_t bluetoothd_init();
+int8_t bluetoothd_exit();
+int8_t bluetoothd_disable_profile(const char *profile);
+int8_t bluetoothd_enable_profile(const char *profile);
+
+
+#endif /* __H_BLUETOOTHD_DBUS_H__ */
diff -urNaw bluez-utils-2.18.orig/daemon/bluetoothd_internal.h bluetoothd-0.0.4/daemon/bluetoothd_internal.h
--- bluez-utils-2.18.orig/daemon/bluetoothd_internal.h 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/bluetoothd_internal.h 2005-07-15 14:17:57.113412424 -0300
@@ -0,0 +1,70 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef __H_BLUETOOTHD_INTERNAL_H__
+#define __H_BLUETOOTHD_INTERNAL_H__
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <dbus/dbus.h>
+
+#include <sys/syslog.h>
+
+#include "dbus.h"
+
+
+
+#define CHECK_DBUS_VERSION(major, minor) \
+ (DBUS_MAJOR_VER > (major) || \
+ (DBUS_MAJOR_VER == (major) && DBUS_MINOR_VER >= (minor)))
+
+
+#if CHECK_DBUS_VERSION(0, 30)
+ #define DBUS_BUS_REQUEST_NAME(x,y,z,w) dbus_bus_request_name(x,y,z,w)
+#else /* < 0.30 */
+ #define DBUS_BUS_REQUEST_NAME(x,y,z,w) dbus_bus_acquire_service(x,y,z,w)
+ #define DBUS_INTERFACE_LOCAL DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL
+ #define DBUS_INTERFACE_DBUS DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS
+#endif
+
+typedef int8_t register_function_t(DBusConnection*);
+typedef int8_t unregister_function_t(DBusConnection*);
+typedef DBusMessage* (service_handler_func_t)(DBusMessage *, void *);
+
+typedef struct
+{
+ const char *name;
+ service_handler_func_t *handler_func;
+ const char *signature; /* TODO */
+}__attribute__((packed))service_table_t;
+
+
+
+#endif /* __H_BLUETOOTHD_INTERNAL_H__ */
diff -urNaw bluez-utils-2.18.orig/daemon/dbus.h bluetoothd-0.0.4/daemon/dbus.h
--- bluez-utils-2.18.orig/daemon/dbus.h 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/dbus.h 2005-07-15 14:17:57.111412728 -0300
@@ -0,0 +1,62 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef __H_BLUETOOTHD_H__
+#define __H_BLUETOOTHD_H__
+
+/* bluetoothd D-Bus services */
+#define BLUETOOTHD_DBUS_SERVICE "org.bluez.bluetoothd"
+#define BLUETOOTHD_DBUS_IFACE_REQ BLUETOOTHD_DBUS_SERVICE".request"
+#define BLUETOOTHD_DBUS_IFACE_SIGNAL BLUETOOTHD_DBUS_SERVICE".signal"
+#define BLUETOOTHD_DBUS_OBJ_PATH "/org/bluez/bluetoothd"
+
+#define BLUETOOTHD_SVC_PERIODIC_INQ_REQ "PeriodicInq"
+#define BLUETOOTHD_SVC_INQ_REQ "Inquiry"
+#define BLUETOOTHD_SVC_SCAN_REQ "Scan"
+#define BLUETOOTHD_SVC_GET_DEVICES_REQ "GetDev"
+#define BLUETOOTHD_SVC_LIST_SERVICES_REQ "ListServices"
+#define BLUETOOTHD_SVC_EXIT_REQ "Exit"
+
+#define BLUETOOTHD_SIGNAL_NEW_DEVICE "NewDev"
+#define BLUETOOTHD_SIGNAL_EXITING "Exiting"
+
+/* pan D-Bus services */
+#define PAN_DBUS_SERVICE BLUETOOTHD_DBUS_SERVICE".pan"
+#define PAN_DBUS_IFACE_REQ BLUETOOTHD_DBUS_SERVICE".pan.request"
+#define PAN_DBUS_IFACE_SIGNAL BLUETOOTHD_DBUS_SERVICE".pan.signal"
+#define PAN_DBUS_PATH BLUETOOTHD_DBUS_OBJ_PATH"/pan"
+
+#define PAN_SVC_CONN_REQ "Connect"
+#define PAN_SVC_DISCONN_REQ "Disconnect"
+#define PAN_SVC_SHOW_REQ "Show"
+#define PAN_SVC_IFCONFIG_REQ "Ifconfig" /* Used for set IP, netmask, bcast */
+
+/* sdp D-Bus services */
+#define SDP_DBUS_SERVICE BLUETOOTHD_DBUS_SERVICE".sdp"
+#define SDP_DBUS_IFACE_REQ BLUETOOTHD_DBUS_SERVICE".sdp.request"
+#define SDP_DBUS_IFACE_SIGNAL BLUETOOTHD_DBUS_SERVICE".sdp.signal"
+#define SDP_DBUS_PATH BLUETOOTHD_DBUS_OBJ_PATH"/sdp"
+#define SDP_SVC_SEARCH_REQ "Search"
+#define SDP_SVC_BROWSE_REQ "Browse"
+
+
+#endif /* __H_BLUETOOTHD_H__ */
diff -urNaw bluez-utils-2.18.orig/daemon/main.c bluetoothd-0.0.4/daemon/main.c
--- bluez-utils-2.18.orig/daemon/main.c 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/main.c 2005-07-15 14:17:57.111412728 -0300
@@ -0,0 +1,113 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <getopt.h>
+
+#include <sys/socket.h>
+#include <sys/syslog.h>
+#include <sys/types.h>
+
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+#include <bluetooth/hci_lib.h>
+
+#include <dbus/dbus.h>
+
+#include "bluetoothd_dbus.h"
+
+
+static struct option main_lopts[] = {
+{ "help", 0, 0, 'h' },
+{ "nodetach", 0, 0, 'n' },
+{ "disable", 1, 0, 'd' },
+{ 0, 0, 0, 0 }
+};
+
+static char main_sopts[] = "hnd:";
+
+static char main_help[] =
+ "Bluetooth D-Bus daemon version " VERSION " \n"
+ "Usage:\n"
+ "\tbluetoothd <options>\n"
+ "Options:\n"
+ "\t--nodetach -n Do not become a daemon\n"
+ "\t--disable -d <profile> Disable a profile\n"
+
+
+ "\n\nProfile:\n"
+ "\tPAN DUN HID ...\n";
+
+int main(int argc, char *argv[])
+{
+ int8_t detach = 1;
+ int8_t opt;
+
+ while ((opt=getopt_long(argc, argv, main_sopts, main_lopts, NULL)) != -1) {
+ switch(opt) {
+ case 'n':
+ detach = 0;
+ break;
+ case 'd':
+ bluetoothd_disable_profile(optarg);
+ break;
+ case 'h':
+ default:
+ printf(main_help);
+ exit(0);
+ }
+ }
+
+ if (detach) {
+ if (fork()) exit(0);
+
+ /* Direct stdin,stdout,stderr to '/dev/null' */
+ {
+ int fd = open("/dev/null", O_RDWR);
+ dup2(fd, 0); dup2(fd, 1); dup2(fd, 2);
+ close(fd);
+ }
+
+ setsid();
+ chdir("/");
+ }
+
+ openlog("bluetoothd", LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_DAEMON);
+ syslog(LOG_INFO, "Bluetooth D-Bus daemon version %s", VERSION);
+
+ bluetoothd_init();
+ bluetoothd_exit();
+
+ return 0;
+}
diff -urNaw bluez-utils-2.18.orig/daemon/Makefile.am bluetoothd-0.0.4/daemon/Makefile.am
--- bluez-utils-2.18.orig/daemon/Makefile.am 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/Makefile.am 2005-07-15 14:17:57.112412576 -0300
@@ -0,0 +1,17 @@
+#
+# $Id: Makefile.am,v 1.2 2005/07/04 17:29:17 holtmann Exp $
+#
+
+if DBUS
+sbin_PROGRAMS = bluetoothd
+
+bluetoothd_SOURCES = main.c bluetoothd_dbus.c pan_dbus.c
+
+bluetoothd_LDADD = @DBUS_LIBS@ @BLUEZ_LIBS@ $(top_builddir)/common/libtextfile.a
+endif
+
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@
+
+INCLUDES = -I$(top_srcdir)/common
+
+MAINTAINERCLEANFILES = Makefile.in
diff -urNaw bluez-utils-2.18.orig/daemon/pan_dbus.c bluetoothd-0.0.4/daemon/pan_dbus.c
--- bluez-utils-2.18.orig/daemon/pan_dbus.c 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/pan_dbus.c 2005-07-15 14:17:57.114412272 -0300
@@ -0,0 +1,136 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#include "pan_dbus.h"
+
+
+static DBusHandlerResult _pan_msg_func(DBusConnection *conn,
+ DBusMessage *msg, void *data);
+
+
+/**
+ * Virtual table that implements the handlers
+ * of the object path hierarchy
+ **/
+static DBusObjectPathVTable pan_vtable = {
+ NULL,
+ &_pan_msg_func,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+
+static DBusMessage* handle_conn_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_disconn_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_show_req(DBusMessage *msg, void *data);
+
+static service_table_t pan_services[] = {
+ {PAN_SVC_CONN_REQ, handle_conn_req },
+ {PAN_SVC_DISCONN_REQ, handle_disconn_req },
+ {PAN_SVC_SHOW_REQ, handle_show_req },
+ {NULL, NULL}
+};
+
+int8_t pan_dbus_register(DBusConnection* conn)
+{
+ int8_t ret = 0;
+
+ if(!dbus_connection_register_fallback (conn, PAN_DBUS_PATH, &pan_vtable, NULL)) {
+ syslog(LOG_ERR,"DBUS failed to register %s object", PAN_DBUS_PATH);
+ }
+ // TODO add filter
+ return ret;
+}
+
+
+int8_t pan_dbus_unregister(DBusConnection* conn)
+{
+ int8_t ret = 0;
+
+ if(!dbus_connection_unregister_object_path(conn, PAN_DBUS_PATH)) {
+ syslog(LOG_ERR,"DBUS failed to unregister %s object", PAN_DBUS_PATH);
+ }
+ // TODO remove filters
+
+ return ret;
+}
+
+static DBusHandlerResult _pan_msg_func(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ service_table_t *ptr_handlers = pan_services;
+ DBusMessage *reply = NULL;
+ DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ uint16_t type;
+ const char *iface;
+ const char *method;
+
+ type = dbus_message_get_type(msg);
+ iface = dbus_message_get_interface(msg);
+ method = dbus_message_get_member (msg);
+
+ if((type == DBUS_MESSAGE_TYPE_METHOD_CALL) &&
+ (strcmp(iface, PAN_DBUS_IFACE_REQ) == 0) &&
+ (method != NULL)){
+ for (;ptr_handlers->name; ptr_handlers++) {
+ if (strcmp(method, ptr_handlers->name) == 0) {
+ reply = (ptr_handlers->handler_func)(msg, data);
+ if (reply) {
+ if (!dbus_connection_send (conn, reply, NULL)) {
+ syslog(LOG_ERR, "%s line:%d Can't send reply message!",
+ __PRETTY_FUNCTION__, __LINE__) ;
+ }
+ dbus_message_unref (reply);
+ }
+ ret = DBUS_HANDLER_RESULT_HANDLED;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+
+
+
+static DBusMessage* handle_conn_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
+static DBusMessage* handle_disconn_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
+static DBusMessage* handle_show_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+
+ return reply;
+}
diff -urNaw bluez-utils-2.18.orig/daemon/pan_dbus.h bluetoothd-0.0.4/daemon/pan_dbus.h
--- bluez-utils-2.18.orig/daemon/pan_dbus.h 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/pan_dbus.h 2005-07-15 14:17:57.110412880 -0300
@@ -0,0 +1,35 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef __H_PAN_DBUS_H__
+#define __H_PAND_DBUS_H__
+
+#include "bluetoothd_internal.h"
+
+
+
+
+
+int8_t pan_dbus_register(DBusConnection* conn);
+int8_t pan_dbus_unregister(DBusConnection* conn);
+
+#endif /* __H_PAND_DBUS_H__ */
diff -urNaw bluez-utils-2.18.orig/daemon/scripts/bluetoothd.conf bluetoothd-0.0.4/daemon/scripts/bluetoothd.conf
--- bluez-utils-2.18.orig/daemon/scripts/bluetoothd.conf 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/scripts/bluetoothd.conf 2005-07-15 14:17:57.106413488 -0300
@@ -0,0 +1,19 @@
+<!-- This configuration file specifies the required security policies
+ for bluez-pand to work. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+ <!-- ../system.conf have denied everything, so we just punch some holes -->
+
+ <policy context="default">
+ <allow own="org.bluez.bluetoothd"/>
+
+ <allow send_destination="org.bluez.bluetoothd"/>
+ <allow receive_sender="org.bluez.bluetoothd"/>
+
+ <allow send_path="/org/bluez/bluetoothd"/>
+ </policy>
+
+</busconfig>
diff -urNaw bluez-utils-2.18.orig/daemon/scripts/bluetoothd.service bluetoothd-0.0.4/daemon/scripts/bluetoothd.service
--- bluez-utils-2.18.orig/daemon/scripts/bluetoothd.service 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/scripts/bluetoothd.service 2005-07-15 14:17:57.106413488 -0300
@@ -0,0 +1,4 @@
+# Service description file
+[D-BUS Service]
+Name=org.bluez.bluetoothd
+Exec=/etc/bluetooth/run-bluetoothd.sh
\ No newline at end of file
diff -urNaw bluez-utils-2.18.orig/daemon/scripts/run-bluetoothd.sh bluetoothd-0.0.4/daemon/scripts/run-bluetoothd.sh
--- bluez-utils-2.18.orig/daemon/scripts/run-bluetoothd.sh 1969-12-31 21:00:00.000000000 -0300
+++ bluetoothd-0.0.4/daemon/scripts/run-bluetoothd.sh 2005-07-15 14:17:57.105413640 -0300
@@ -0,0 +1,2 @@
+#!/bin/sh
+bluetoothd
\ No newline at end of file
next prev parent reply other threads:[~2005-07-15 17:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-12 20:47 [Bluez-devel] bluetoothd specification Claudio Takahasi
2005-07-15 17:37 ` Claudio Takahasi [this message]
2005-07-18 16:12 ` [Bluez-devel] " Frederic Danis
2005-07-18 16:46 ` Claudio Takahasi
2005-07-26 16:31 ` [Bluez-devel] Re: bluetoothd specification - new patch Claudio Takahasi
2005-07-26 17:18 ` Marcel Holtmann
2005-07-26 19:06 ` Claudio Takahasi
2005-07-26 21:57 ` Marcel Holtmann
2005-07-28 14:08 ` Claudio Takahasi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1effdeb050715103731d599d7@mail.gmail.com \
--to=cktakahasi@gmail.com \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.