/* Service level Authorization request callback */
typedef void (*authorize_request_callback) (bt_bdaddr_t *remote_bd_addr, bt_service_id_t service_d);
+#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);
+#endif
/** TODO: Add callbacks for Link Up/Down and other generic
* notifications/callbacks */
energy_info_callback energy_info_cb;
authorize_request_callback authorize_request_cb;
device_trust_state_changed_callback device_trust_state_changed_cb;
+#ifdef TIZEN_BT_HAL
+ sock_authorize_request_callback socket_authorize_request_cb;
+#endif
} bt_callbacks_t;
typedef void (*alarm_cb)(void *data);
uint32_t service_id;
} __attribute__((packed));
+#ifdef TIZEN_BT_HAL
+#define HAL_EV_SOCK_AUTHORIZE_REQUEST 0x90
+struct hal_ev_sock_conn_auth {
+ uint8_t uuid[16];
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+#endif //TIZEN_BT_HAL
+
#define HAL_ACL_STATE_CONNECTED 0x00
#define HAL_ACL_STATE_DISCONNECTED 0x01
#include "bt-hal-dbus-common-utils.h"
#include "bt-hal-adapter-dbus-handler.h"
+#include "bt-hal-rfcomm-dbus-handler.h"
#include "bt-hal-event-receiver.h"
#include <bt-hal-agent.h>
}
#endif
+#ifdef TIZEN_BT_HAL
+static void __bt_hal_send_rfcomm_authorize_request_event(const gchar *address, const char *uuid)
+{
+ struct hal_ev_sock_conn_auth ev;
+
+ DBG("Remote Device address [%s], uuid: %s", address, uuid);
+
+ memset(&ev, 0, sizeof(ev));
+ _bt_convert_addr_string_to_type(ev.bdaddr, address);
+ _bt_convert_uuid_string_to_type(ev.uuid, uuid);
+
+ handle_stack_msg event_cb = _bt_hal_get_stack_message_handler();
+ if (event_cb) {
+ DBG("Sending Socket AUTHORIZE REQUEST");
+ event_cb(HAL_EV_SOCK_AUTHORIZE_REQUEST, (void*)&ev, sizeof(ev));
+ }
+
+ DBG("-");
+}
+#endif
+
/* Legacy Pairing */
static void __bt_hal_send_pin_request_event(const gchar *address, const gchar *name,
uint32_t cod)
INFO("Device is not Trusted, so prompt user to accept or reject authorization \n");
}
+#ifdef TIZEN_BT_HAL
+ if (_is_rfcomm_server_uuid(uuid)) {
+ __bt_hal_send_rfcomm_authorize_request_event(address, uuid);
+ goto done;
+ }
+#endif
+
/*
* TODO: Handling for authorization request for different profiles will be
* implemented while profiles support is added. For now send all the request
DBG("-");
}
+#ifdef TIZEN_BT_HAL
+static void __bt_hal_handle_socket_authorize_request_event(void *buf, uint16_t len)
+{
+ struct hal_ev_sock_conn_auth *ev = buf;
+ bt_bdaddr_t bd_addr;
+ bt_uuid_t uuid;
+
+ DBG("+");
+
+ memcpy(bd_addr.address, ev->bdaddr, 6);
+ memcpy(uuid.uu, ev->uuid, 16);
+
+ 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);
+ DBG("-");
+}
+#endif
+
static void __bt_hal_handle_ssp_request_event(void *buf, uint16_t len)
{
struct hal_ev_ssp_request *ev = (struct hal_ev_ssp_request *)buf;
DBG("Event: HAL_EV_DEVICE_TRUST_CHANGED");
__bt_hal_handle_device_trust_state_changed_event(buf, len);
break;
+#ifdef TIZEN_BT_HAL
+ case HAL_EV_SOCK_AUTHORIZE_REQUEST:
+ DBG("Event: HAL_EV_AUTHORIZE_REQUEST");
+ __bt_hal_handle_socket_authorize_request_event(buf, len);
+ break;
+#endif
default:
DBG("Event Currently not handled!!");
break;
return -1;
}
+ /* Remove local reference to client socket fd */
+ close(fd);
return 0;
}
DBG("-");
return BT_STATUS_SUCCESS;
}
+
+gboolean _is_rfcomm_server_uuid(const char *uuid)
+{
+ DBG("+");
+
+ if (!uuid)
+ return FALSE;
+
+ if (NULL == __find_rfcomm_server_info_from_uuid(uuid))
+ return FALSE;
+
+ DBG("-");
+ return TRUE;
+}
int _bt_hal_dbus_handler_rfcomm_listen(
const char *svc_name, unsigned char *uuid, int *sock);
+gboolean _is_rfcomm_server_uuid(const char *uuid);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */