struct hal_ev_sock_conn_auth {
uint8_t uuid[16];
uint8_t bdaddr[6];
+ uint8_t name[249];
+ uint8_t path[249];
+ uint32_t fd;
} __attribute__((packed));
#endif //TIZEN_BT_HAL
}
#ifdef TIZEN_BT_HAL
-static void __bt_hal_send_rfcomm_authorize_request_event(const gchar *address, const char *uuid)
+static void __bt_hal_send_rfcomm_authorize_request_event(const gchar *address, const char *uuid, const char *name, char *path, int fd)
{
struct hal_ev_sock_conn_auth ev;
memset(&ev, 0, sizeof(ev));
_bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
_bt_hal_convert_uuid_string_to_type(ev.uuid, uuid);
+ if (name)
+ memcpy(ev.name, name, strlen(name) - 1);
+ if (path)
+ memcpy(ev.path, path, strlen(path) - 1);
+ ev.fd = fd;
handle_stack_msg event_cb = _bt_hal_get_stack_message_handler();
if (event_cb) {
GVariant *reply = NULL;
GVariant *reply_temp = NULL;
GVariant *tmp_value;
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
+ bt_hal_agent_osp_server_t *osp_server;
+#endif
DBG("Authorize Request from Bluez Stack: UUID [%s]", uuid);
#ifdef TIZEN_BT_HAL
if (!strcasecmp(uuid, BT_HAL_OPP_UUID)) {
if (NULL != _bt_hal_gap_agent_find_osp_server_by_type(
- agent->osp_servers, BT_OSP_SERVER_OBEX)) {
+ agent->osp_servers, BT_OSP_SERVER_OBEX, NULL)) {
INFO("OSP server for OPP found, send event");
__bt_hal_send_authorize_request_event(address, uuid);
goto done;
}
}
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
+ /* If user only listens(without accepts) to rfcomm server, occurs connection requested cb not popup */
+ osp_server = _bt_hal_gap_agent_find_osp_server_by_type(agent->osp_servers, BT_OSP_SERVER_RFCOMM, uuid);
+ if (osp_server) {
+ INFO("Found rfcomm osp server. path: %s, fd: %d", osp_server->path, osp_server->fd);
+ __bt_hal_send_rfcomm_authorize_request_event(address, uuid, name, osp_server->path, osp_server->fd);
+ goto done;
+ }
+#else
if (_is_rfcomm_server_uuid(uuid)) {
- __bt_hal_send_rfcomm_authorize_request_event(address, uuid);
+ __bt_hal_send_rfcomm_authorize_request_event(address, uuid, NULL, NULL, -1);
goto done;
}
#endif
+#endif
if (trust || !headed_plugin_info->plugin_headed_enabled) {
INFO("Trusted or Headless device, so authorize\n");
return _bt_hal_device_get_service_connection_state(bd_addr, rem_svc_id);
}
-static int set_agent_osp_server(uint32_t type, uint8_t enable)
+static int register_agent_osp_server(uint32_t type, char *uuid, char *path, int fd)
{
DBG("");
- return _bt_hal_device_set_osp_server(type, enable);
+ return _bt_hal_device_register_osp_server(type, uuid, path, fd);
+}
+
+static int unregister_agent_osp_server(uint32_t type, char *uuid)
+{
+ DBG("");
+ return _bt_hal_device_unregister_osp_server(type, uuid);
}
static int set_trusted_profile(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint8_t trust)
.set_authorization = set_authorization,
#ifdef TIZEN_BT_HAL
.get_service_connection_state = get_service_connection_state,
- .set_agent_osp_server = set_agent_osp_server,
+ .register_agent_osp_server = register_agent_osp_server,
+ .unregister_agent_osp_server = unregister_agent_osp_server,
.set_trusted_profile = set_trusted_profile,
.get_trusted_profile = get_trusted_profile,
.enable_rssi_monitoring = enable_rssi_monitoring,
struct hal_ev_sock_conn_auth *ev = buf;
bt_bdaddr_t bd_addr;
bt_uuid_t uuid;
+ uint8_t name[249] = {0, };
+ uint8_t path[249] = {0, };
+ uint32_t fd;
DBG("+");
memcpy(bd_addr.address, ev->bdaddr, 6);
memcpy(uuid.uu, ev->uuid, 16);
+ memcpy(name, ev->name, sizeof(name) - 1);
+ memcpy(path, ev->path, sizeof(name) - 1);
+ fd = ev->fd;
if (!bt_hal_cbacks->socket_authorize_request_cb) {
ERR("HAL User socket_authorize_request_cb is not set!!");
return;
}
- bt_hal_cbacks->socket_authorize_request_cb(&bd_addr, &uuid);
+ bt_hal_cbacks->socket_authorize_request_cb(&bd_addr, &uuid, name, path, fd);
DBG("-");
}
#endif
return 1;
}
-int _bt_hal_device_set_osp_server(uint32_t type, gboolean enable)
+int _bt_hal_device_register_osp_server(uint32_t type, char *uuid, char *path, int fd)
{
GapAgentPrivate *agent = _bt_hal_get_adapter_agent();
gboolean result = FALSE;
if (!agent)
return BT_STATUS_FAIL;
- if (enable)
- result = _bt_hal_gap_agent_register_osp_server(agent, type);
- else
- result = _bt_hal_gap_agent_unregister_osp_server(agent, type);
+ result = _bt_hal_gap_agent_register_osp_server(agent, type, uuid, path, fd);
+ if (!result)
+ return BT_STATUS_FAIL;
+
+ DBG("-");
+ return BT_STATUS_SUCCESS;
+}
+
+int _bt_hal_device_unregister_osp_server(uint32_t type, char *uuid)
+{
+ GapAgentPrivate *agent = _bt_hal_get_adapter_agent();
+ gboolean result = FALSE;
+
+ DBG("+");
+ if (!agent)
+ return BT_STATUS_FAIL;
+ result = _bt_hal_gap_agent_unregister_osp_server(agent, type, uuid);
if (!result)
return BT_STATUS_FAIL;
int _bt_hal_device_get_service_connection_state(
const bt_bdaddr_t *bd_addr, bt_service_id_t rem_svc_id);
-int _bt_hal_device_set_osp_server(uint32_t type, gboolean enable);
-
+int _bt_hal_device_register_osp_server(uint32_t type, char *uuid, char *path, int fd);
+int _bt_hal_device_unregister_osp_server(uint32_t type, char *uuid);
int _bt_hal_device_set_trusted_profile(const bt_bdaddr_t *bd_addr,
bt_trusted_profile_t profile, uint8_t trust);
if (!server)
return;
- /* TODO: Free additional elements if present */
+ g_free(server->uuid);
+ g_free(server->path);
g_free(server);
DBG("-");
}
#ifdef TIZEN_BT_HAL
-bt_hal_agent_osp_server_t *_bt_hal_gap_agent_find_osp_server_by_type(GSList *servers, unsigned int type)
+bt_hal_agent_osp_server_t *_bt_hal_gap_agent_find_osp_server_by_type(GSList *servers, unsigned int type, const char *uuid)
{
GSList *l;
bt_hal_agent_osp_server_t *server;
if (server == NULL)
continue;
- if (type == server->type)
+ /* No uuid in obex server */
+ if (type == BT_OSP_SERVER_OBEX
+ && server->type == BT_OSP_SERVER_OBEX)
+ return server;
+
+ if (g_strcmp0(server->uuid, uuid) == 0)
return server;
}
return NULL;
}
-gboolean _bt_hal_gap_agent_register_osp_server(GapAgentPrivate *agent, unsigned int type)
+gboolean _bt_hal_gap_agent_register_osp_server(GapAgentPrivate *agent, unsigned int type, char *uuid, char *path, int fd)
{
bt_hal_agent_osp_server_t *server;
server = g_malloc0(sizeof(bt_hal_agent_osp_server_t));
server->type = type;
+ if (type == BT_OSP_SERVER_RFCOMM && uuid && path) {
+ server->uuid = g_strdup(uuid);
+ server->path = g_strdup(path);
+ server->fd = fd;
+ }
priv->osp_servers = g_slist_append(priv->osp_servers, server);
DBG("-");
return TRUE;
}
-gboolean _bt_hal_gap_agent_unregister_osp_server(GapAgentPrivate *agent, unsigned int type)
+gboolean _bt_hal_gap_agent_unregister_osp_server(GapAgentPrivate *agent, unsigned int type, char *uuid)
{
bt_hal_agent_osp_server_t *server;
if (type >= BT_OSP_SERVER_MAX)
return FALSE;
- server = _bt_hal_gap_agent_find_osp_server_by_type(priv->osp_servers, type);
+ server = _bt_hal_gap_agent_find_osp_server_by_type(priv->osp_servers, type, uuid);
if (server == NULL)
return TRUE;
#ifdef TIZEN_BT_HAL
typedef struct {
unsigned int type;
- /* TODO: Add more elements If and when required */
+ char *uuid;
+ char *path;
+ int fd;
} bt_hal_agent_osp_server_t;
#endif
GDBusMethodInvocation *context);
#ifdef TIZEN_BT_HAL
-bt_hal_agent_osp_server_t *_bt_hal_gap_agent_find_osp_server_by_type(GSList *servers, unsigned int type);
+bt_hal_agent_osp_server_t *_bt_hal_gap_agent_find_osp_server_by_type(GSList *servers, unsigned int type, const char *uuid);
-gboolean _bt_hal_gap_agent_register_osp_server(GapAgentPrivate *agent, unsigned int type);
+gboolean _bt_hal_gap_agent_register_osp_server(GapAgentPrivate *agent, unsigned int type, char *uuid, char *path, int fd);
-gboolean _bt_hal_gap_agent_unregister_osp_server(GapAgentPrivate *agent, unsigned int type);
+gboolean _bt_hal_gap_agent_unregister_osp_server(GapAgentPrivate *agent, unsigned int type, char *uuid);
#endif
#endif //_BT_HAL_GAP_AGENT_H__
#ifdef TIZEN_BT_HAL
#define BT_OSP_SERVER_OBEX 0x00
-/* TODO: Add more types If and when required */
+#define BT_OSP_SERVER_RFCOMM 0x01
#define BT_OSP_SERVER_MAX 0xFF
/* Tizen BT discovery Types */
#ifdef TIZEN_BT_HAL
/* Service level Authorization request callback */
-typedef void (*sock_authorize_request_callback) (bt_bdaddr_t *remote_bd_addr, bt_uuid_t *uuid);
+typedef void (*sock_authorize_request_callback) (bt_bdaddr_t *remote_bd_addr, bt_uuid_t *uuid, uint8_t *name, uint8_t *path, uint32_t fd);
/** Bluetooth ACL connection state */
typedef enum {
int (*get_service_connection_state)(const bt_bdaddr_t *bd_addr, bt_service_id_t rem_svc_id);
/*
- * Enable/Disable osp server in gap agent.
- * enable == 0/1 -> Register/Unregister osp server.
+ * Register osp server in gap agent.
*/
- int (*set_agent_osp_server)(uint32_t type, uint8_t enable);
+ int (*register_agent_osp_server)(uint32_t type, char *uuid, char *path, int fd);
+
+ /*
+ * Unregister osp server in gap agent.
+ */
+ int (*unregister_agent_osp_server)(uint32_t type, char *uuid);
/**
* Set profile as trusted for remote device
*/
typedef enum {
- CONN_TYPE_DEFAULT = 0xFF, /* represents that connection type can both BR/EDR and LE */
- CONN_TYPE_BREDR = 0x00,
- CONN_TYPE_LE = 0x01,
-} connection_type_e;
+ OAL_CONN_TYPE_DEFAULT = 0xFF, /* represents that connection type can both BR/EDR and LE */
+ OAL_CONN_TYPE_BREDR = 0x00,
+ OAL_CONN_TYPE_LE = 0x01,
+} oal_conn_type_e;
/**
* @brief OSP server type
*
* @see device_set_osp_server()
+ * @see device_register_osp_server()
*/
typedef enum {
OAL_OSP_SERVER_OBEX = 0x00,
- /*TODO: Add more server type if and when required */
+ OAL_OSP_SERVER_RFCOMM
} oal_osp_server_type_e;
/**
* @see OAL_EVENT_DEVICE_BONDING_SUCCESS
* @see OAL_EVENT_DEVICE_BONDING_FAILED
*/
-oal_status_t device_create_bond(bt_address_t * addr, connection_type_e transport);
+oal_status_t device_create_bond(bt_address_t * addr, oal_conn_type_e transport);
/**
* @brief Cancel already in-progress bonding procedure
gboolean device_get_svc_conn_state(bt_address_t * addr, oal_service_t svc_id);
/**
- * @brief Set OSP server status in GAP agent
+ * @brief Register OSP server in GAP agent
*
- * @details This API is to enable/disable OSP server in GAP agent. if OSP server is enabled,
+ * @details This API is to register OSP server in GAP agent. if OSP server is enabled,
* connection authorization events are sent to application otherwise handled internally in HAL.
*
- * @param[in] tpye : OSP Server type
- * @param[in] enable: 0 -> enable server, 1 -> Disable server
+ * @param[in] type: OSP Server type
+ * @param[in] uuid: UUID
+ * @param[in] path: Dbus path
+ * @param[in] fd: Socket fd
*
* @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
*
* @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
*/
-oal_status_t device_set_osp_server(oal_osp_server_type_e type, int enable);
+oal_status_t device_register_osp_server(oal_osp_server_type_e type, char *uuid, char *path, int fd);
+
+/**
+ * @brief Unregister OSP server in GAP agent
+ *
+ * @details This API is to unregister OSP server in GAP agent. if OSP server is enabled,
+ * connection authorization events are sent to application otherwise handled internally in HAL.
+ *
+ * @param[in] type: OSP Server type
+ * @param[in] uuid: UUID
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ */
+oal_status_t device_unregister_osp_server(oal_osp_server_type_e type, char *uuid);
/**
* @brief Set profile trust info for remote device
typedef struct {
bt_address_t address;
oal_uuid_t uuid;
+ uint8_t name[249];
+ uint8_t path[249];
+ uint32_t fd;
} event_socket_authorize_req_t;
typedef struct {
extern void cb_device_authorize_request(bt_bdaddr_t *remote_bd_addr, bt_service_id_t service_d);
extern void cb_device_trust_state_changed(bt_bdaddr_t *remote_bd_addr, bt_device_trust_state_t trusted);
#ifdef TIZEN_BT_HAL
-extern void cb_socket_conn_authorize_request(bt_bdaddr_t *remote_bd_addr, bt_uuid_t *uuid);
+extern void cb_socket_conn_authorize_request(bt_bdaddr_t *remote_bd_addr, bt_uuid_t *uuid, uint8_t *name, uint8_t *path, uint32_t fd);
static void cb_ble_state_change(bt_state_t status);
extern void cb_device_le_conn_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
bt_le_conn_state_t state);
return OAL_STATUS_SUCCESS;
}
-oal_status_t device_create_bond(bt_address_t *addr, connection_type_e transport)
+oal_status_t device_create_bond(bt_address_t *addr, oal_conn_type_e transport)
{
int res;
bdstr_t bdstr;
return res;
}
-oal_status_t device_set_osp_server(oal_osp_server_type_e type, int enable)
+oal_status_t device_register_osp_server(oal_osp_server_type_e type, char *uuid, char *path, int fd)
{
int res;
uint32_t server_type;
case OAL_OSP_SERVER_OBEX:
server_type = BT_OSP_SERVER_OBEX;
break;
+ case OAL_OSP_SERVER_RFCOMM:
+ server_type = BT_OSP_SERVER_RFCOMM;
+ break;
+ default:
+ BT_ERR("unknown type: %d", type);
+ return OAL_STATUS_INVALID_PARAM;
+ }
+
+ res = blued_api->register_agent_osp_server(server_type, uuid, path, fd);
+ if (res != BT_STATUS_SUCCESS) {
+ BT_ERR("register_agent_osp_server error: [%s]", status2string(res));
+ return convert_to_oal_status(res);
+ }
+
+ return OAL_STATUS_SUCCESS;
+#else
+ BT_ERR("Not supported");
+ res = OAL_STATUS_NOT_SUPPORT;
+ return res;
+#endif
+}
+
+oal_status_t device_unregister_osp_server(oal_osp_server_type_e type, char *uuid)
+{
+ int res;
+ uint32_t server_type;
+
+ CHECK_OAL_INITIALIZED();
+
+ API_TRACE("type: %d", type);
+
+#ifdef TIZEN_BT_HAL
+ switch (type) {
+ case OAL_OSP_SERVER_OBEX:
+ server_type = BT_OSP_SERVER_OBEX;
+ break;
+ case OAL_OSP_SERVER_RFCOMM:
+ server_type = BT_OSP_SERVER_RFCOMM;
+ break;
default:
BT_ERR("unknown type: %d", type);
return OAL_STATUS_INVALID_PARAM;
}
- res = blued_api->set_agent_osp_server(server_type, enable);
+ res = blued_api->unregister_agent_osp_server(server_type, uuid);
if (res != BT_STATUS_SUCCESS) {
- BT_ERR("set_agent_osp_server error: [%s]", status2string(res));
+ BT_ERR("unregister_agent_osp_server error: [%s]", status2string(res));
return convert_to_oal_status(res);
}
}
#ifdef TIZEN_BT_HAL
-void cb_socket_conn_authorize_request(bt_bdaddr_t *bd_addr, bt_uuid_t *uuid)
+void cb_socket_conn_authorize_request(bt_bdaddr_t *bd_addr, bt_uuid_t *uuid, uint8_t *name, uint8_t *path, uint32_t fd)
{
event_socket_authorize_req_t *auth_req = g_new0(event_socket_authorize_req_t, 1);
memcpy(auth_req->address.addr, bd_addr->address, 6);
memcpy(auth_req->uuid.uuid, uuid->uu, 16);
+ memcpy(auth_req->name, name, sizeof(auth_req->name) - 1);
+ memcpy(auth_req->path, path, sizeof(auth_req->path) - 1);
+ auth_req->fd = fd;
send_event_bda_trace(OAL_EVENT_SOCKET_AUTHORIZE_REQUEST, auth_req, sizeof(event_socket_authorize_req_t), (bt_address_t*)bd_addr);
}
#include "bt-service-common.h"
#include <oal-manager.h>
+#include <oal-device-mgr.h>
#ifdef TIZEN_FEATURE_BT_IPSP
static GDBusProxy *ipsp_proxy;
#if TODO_40 /* Need to add this function */
if (!_bt_agent_register_osp_server(type, uuid, path, fd))
return BLUETOOTH_ERROR_INTERNAL;
+#else
+ if (device_register_osp_server(type, uuid, path, fd) != 0)
+ return BLUETOOTH_ERROR_INTERNAL;
#endif
return BLUETOOTH_ERROR_NONE;
}
#if TODO_40 /* Need to add this function */
if (!_bt_agent_unregister_osp_server(type, uuid))
return BLUETOOTH_ERROR_INTERNAL;
+#else
+ if (device_unregister_osp_server(type, uuid) != 0)
+ return BLUETOOTH_ERROR_INTERNAL;
#endif
return BLUETOOTH_ERROR_NONE;
}
agent_info.native_server->app_pid = app_pid;
agent_info.server_type = BT_NATIVE_SERVER;
if (OAL_STATUS_SUCCESS !=
- device_set_osp_server(OAL_OSP_SERVER_OBEX, FALSE))
- BT_ERR("device_set_osp_server failed");
+ device_unregister_osp_server(OAL_OSP_SERVER_OBEX, NULL))
+ BT_ERR("device_unregister_osp_server failed");
} else {
if (agent_info.custom_server) {
BT_ERR("obex custom server busy");
agent_info.custom_server->app_pid = app_pid;
agent_info.server_type = BT_CUSTOM_SERVER;
if (OAL_STATUS_SUCCESS !=
- device_set_osp_server(OAL_OSP_SERVER_OBEX, TRUE))
- BT_ERR("device_set_osp_server failed");
+ device_register_osp_server(OAL_OSP_SERVER_OBEX, NULL, NULL, -1))
+ BT_ERR("device_register_osp_server failed");
}
g_free(dst_path);
agent_info.server_type = BT_CUSTOM_SERVER;
if (OAL_STATUS_SUCCESS !=
- device_set_osp_server(OAL_OSP_SERVER_OBEX, TRUE))
- BT_ERR("device_set_osp_server failed");
+ device_register_osp_server(OAL_OSP_SERVER_OBEX, NULL, NULL, -1))
+ BT_ERR("device_register_osp_server failed");
}
} else {
retv_if(agent_info.custom_server == NULL,
agent_info.server_type = BT_NATIVE_SERVER;
if (OAL_STATUS_SUCCESS !=
- device_set_osp_server(OAL_OSP_SERVER_OBEX, FALSE))
- BT_ERR("device_set_osp_server failed");
+ device_unregister_osp_server(OAL_OSP_SERVER_OBEX, NULL))
+ BT_ERR("device_unregister_osp_server failed");
}
}
char address[BT_ADDRESS_STRING_SIZE];
char uuid_str[BT_UUID_STRING_SIZE];
int result = BLUETOOTH_ERROR_NONE;
+ char name[249] = {0, };
+ char path[249] = {0, };
+ int fd;
BT_DBG("+");
_bt_convert_addr_type_to_string(address, auth_event->address.addr);
_bt_service_convert_uuid_type_to_string(uuid_str, auth_event->uuid.uuid);
- BT_INFO("Address: %s, UUID: %s", address, uuid_str);
+ memcpy(name, auth_event->name, sizeof(auth_event->name) - 1);
+ memcpy(path, auth_event->path, sizeof(auth_event->path) - 1);
+ fd = auth_event->fd;
+ BT_INFO("Address: %s, UUID: %s, Name: %s, Path: %s, Fd: %d", address, uuid_str, name, path, fd);
_bt_send_event(BT_RFCOMM_SERVER_EVENT,
BLUETOOTH_EVENT_RFCOMM_AUTHORIZE,
- g_variant_new("(iss)", result, address, uuid_str));
+ g_variant_new("(issssn)", result, address, uuid_str, name, path, fd));
BT_DBG("-");
}