#include "profiles/audio/a2dp-codecs.h"
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "a2dp.h"
#include "utils.h"
#define AUDIO_SERVICE_ID 0
#define AUDIO_SERVICE_ID_MAX AUDIO_SERVICE_ID
-#define AUDIO_STATUS_SUCCESS 0x00
+#define AUDIO_STATUS_SUCCESS IPC_STATUS_SUCCESS
#define AUDIO_STATUS_FAILED 0x01
-#define AUDIO_OP_STATUS 0x00
-struct audio_status {
- uint8_t code;
-} __attribute__((packed));
+#define AUDIO_OP_STATUS IPC_OP_STATUS
#define AUDIO_OP_OPEN 0x01
struct audio_preset {
#include "src/sdpd.h"
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "utils.h"
#include "bluetooth.h"
static void update_new_device(struct device *dev, int8_t rssi,
const struct eir_data *eir)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_ev_device_found *ev = (void*) buf;
bdaddr_t android_bdaddr;
uint8_t android_type;
static void update_device(struct device *dev, int8_t rssi,
const struct eir_data *eir)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_ev_remote_device_props *ev = (void *) buf;
int size;
int8_t rssi, bool confirm,
const uint8_t *data, uint8_t data_len)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct eir_data eir;
struct device *dev;
#include <sbc/sbc.h>
#include "audio-msg.h"
+#include "ipc-common.h"
#include "hal-log.h"
#include "hal-msg.h"
#include "../profiles/audio/a2dp-codecs.h"
ssize_t ret;
struct msghdr msg;
struct iovec iv[2];
- struct hal_hdr cmd;
+ struct ipc_hdr cmd;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
- struct hal_status s;
+ struct ipc_status s;
size_t s_len = sizeof(s);
pthread_mutex_lock(&sk_mutex);
}
if (cmd.opcode == AUDIO_OP_STATUS) {
- struct hal_status *s = rsp;
+ struct ipc_status *s = rsp;
if (sizeof(*s) != cmd.len) {
error("audio: Invalid status length");
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
static const btrc_callbacks_t *cbs = NULL;
static bt_status_t list_player_app_attr_rsp(int num_attr,
btrc_player_attr_t *p_attrs)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_list_player_attrs *cmd = (void *) buf;
size_t len;
return BT_STATUS_PARM_INVALID;
len = sizeof(*cmd) + num_attr;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->number = num_attr;
static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_list_player_values *cmd = (void *) buf;
size_t len;
len = sizeof(*cmd) + num_val;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->number = num_val;
static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_player_attrs *cmd = (void *) buf;
size_t len, attrs_len;
int i;
sizeof(struct hal_avrcp_player_attr_value);
len = sizeof(*cmd) + attrs_len;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->number = p_vals->num_attr;
struct hal_avrcp_player_setting_text *value = (void *) ptr;
size_t attr_len = sizeof(*value);
- if (attr_len + *len > BLUEZ_HAL_MTU)
+ if (attr_len + *len > IPC_MTU)
return 0;
value->id = id;
*len += attr_len;
ptr += attr_len;
- if (value->len + *len > BLUEZ_HAL_MTU)
- value->len = BLUEZ_HAL_MTU - *len;
+ if (value->len + *len > IPC_MTU)
+ value->len = IPC_MTU - *len;
memcpy(value->text, text, value->len);
{
int i;
- for (i = 0; i < num_attr && *len < BLUEZ_HAL_MTU; i++) {
+ for (i = 0; i < num_attr && *len < IPC_MTU; i++) {
int ret;
ret = write_text(ptr, p_attrs[i].id, p_attrs[i].text, len);
static bt_status_t get_player_app_attr_text_rsp(int num_attr,
btrc_player_setting_text_t *p_attrs)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_player_attrs_text *cmd = (void *) buf;
uint8_t *ptr;
size_t len;
static bt_status_t get_player_app_value_text_rsp(int num_val,
btrc_player_setting_text_t *p_vals)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_player_values_text *cmd = (void *) buf;
uint8_t *ptr;
size_t len;
{
int i;
- for (i = 0; i < num_attr && *len < BLUEZ_HAL_MTU; i++) {
+ for (i = 0; i < num_attr && *len < IPC_MTU; i++) {
int ret;
ret = write_text(ptr, p_attrs[i].attr_id, p_attrs[i].text, len);
static bt_status_t get_element_attr_rsp(uint8_t num_attr,
btrc_element_attr_val_t *p_attrs)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_element_attrs_text *cmd = (void *) buf;
size_t len;
uint8_t *ptr;
static bt_status_t play_status_changed_rsp(btrc_notification_type_t type,
btrc_play_status_t *play_status)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
size_t len;
static bt_status_t track_change_rsp(btrc_notification_type_t type,
btrc_uid_t *track)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
size_t len;
static bt_status_t play_pos_changed_rsp(btrc_notification_type_t type,
uint32_t *song_pos)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
size_t len;
static bt_status_t settings_changed_rsp(btrc_notification_type_t type,
btrc_player_settings_t *player_setting)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
struct hal_avrcp_player_attr_value *attrs;
size_t len, param_len;
param_len = player_setting->num_attr * sizeof(*attrs);
len = sizeof(*cmd) + param_len;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->event = BTRC_EVT_APP_SETTINGS_CHANGED;
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
#include "hal-utils.h"
static int set_adapter_property(const bt_property_t *property)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_set_adapter_prop *cmd = (void *) buf;
size_t len;
static int set_remote_device_property(bt_bdaddr_t *remote_addr,
const bt_property_t *property)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_set_remote_device_prop *cmd = (void *) buf;
size_t len;
static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t buf_len)
{
- char cmd_buf[BLUEZ_HAL_MTU];
+ char cmd_buf[IPC_MTU];
struct hal_cmd_dut_mode_send *cmd = (void *) cmd_buf;
size_t len;
static int le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t buf_len)
{
- char cmd_buf[BLUEZ_HAL_MTU];
+ char cmd_buf[IPC_MTU];
struct hal_cmd_le_test_mode *cmd = (void *) cmd_buf;
size_t len;
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
static const bthf_callbacks_t *cbs = NULL;
static bt_status_t cops_response(const char *cops)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_cops_response *cmd = (void *) buf;
size_t len;
static bt_status_t formatted_at_response(const char *rsp)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_formatted_at_response *cmd = (void *) buf;
size_t len;
const char *number,
bthf_call_addrtype_t type)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_clcc_response *cmd = (void *) buf;
size_t len;
const char *number,
bthf_call_addrtype_t type)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_phone_state_change *cmd = (void *) buf;
size_t len;
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
static const bthh_callbacks_t *cbacks;
bthh_report_type_t report_type,
char *report)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_cmd_hidhost_set_report *cmd = (void *) buf;
DBG("");
static bt_status_t send_data(bt_bdaddr_t *bd_addr, char *data)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_cmd_hidhost_send_data *cmd = (void *) buf;
DBG("");
#include "hal.h"
#include "hal-msg.h"
#include "hal-log.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
#define CONNECT_TIMEOUT (5 * 1000)
static void handle_msg(void *buf, ssize_t len)
{
- struct hal_hdr *msg = buf;
+ struct ipc_hdr *msg = buf;
const struct hal_ipc_handler *handler;
uint8_t opcode;
struct iovec iv;
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
ssize_t ret;
int fd;
ssize_t ret;
struct msghdr msg;
struct iovec iv[2];
- struct hal_hdr cmd;
+ struct ipc_hdr cmd;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
- struct hal_status s;
+ struct ipc_status s;
size_t s_len = sizeof(s);
if (cmd_sk < 0) {
}
if (cmd.opcode == HAL_OP_STATUS) {
- struct hal_status *s = rsp;
+ struct ipc_status *s = rsp;
if (sizeof(*s) != cmd.len) {
error("Invalid status length, aborting");
*
*/
-#define BLUEZ_HAL_MTU 1024
-
static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
-struct hal_hdr {
- uint8_t service_id;
- uint8_t opcode;
- uint16_t len;
- uint8_t payload[0];
-} __attribute__((packed));
-
#define HAL_MINIMUM_EVENT 0x81
#define HAL_SERVICE_ID_CORE 0
/* Core Service */
-#define HAL_STATUS_SUCCESS 0x00
+#define HAL_STATUS_SUCCESS IPC_STATUS_SUCCESS
#define HAL_STATUS_FAILED 0x01
#define HAL_STATUS_NOT_READY 0x02
#define HAL_STATUS_NOMEM 0x03
#define HAL_STATUS_AUTH_FAILURE 0x09
#define HAL_STATUS_REMOTE_DEVICE_DOWN 0x0a
-#define HAL_OP_STATUS 0x00
-struct hal_status {
- uint8_t code;
-} __attribute__((packed));
+#define HAL_OP_STATUS IPC_OP_STATUS
#define HAL_OP_REGISTER_MODULE 0x01
struct hal_cmd_register_module {
#include "src/shared/hfp.h"
#include "btio/btio.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "handsfree.h"
#include "bluetooth.h"
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "hidhost.h"
#include "utils.h"
--- /dev/null
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#define IPC_MTU 1024
+
+#define IPC_STATUS_SUCCESS 0x00
+
+struct ipc_hdr {
+ uint8_t service_id;
+ uint8_t opcode;
+ uint16_t len;
+ uint8_t payload[0];
+} __attribute__((packed));
+
+#define IPC_OP_STATUS 0x00
+struct ipc_status {
+ uint8_t code;
+} __attribute__((packed));
#include "src/shared/hciemu.h"
#include "hal-msg.h"
+#include "ipc-common.h"
+
#include <cutils/properties.h>
#define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
};
struct regmod_msg {
- struct hal_hdr header;
+ struct ipc_hdr header;
struct hal_cmd_register_module cmd;
} __attribute__((packed));
static bool setup_module(int service_id)
{
- struct hal_hdr response;
- struct hal_hdr expected_response;
+ struct ipc_hdr response;
+ struct ipc_hdr expected_response;
struct regmod_msg btmodule_msg = {
.header = {
#define test_opcode_valid(_name, _service, _opcode, _len, _servicelist...) \
do { \
- static struct hal_hdr hdr = { \
+ static struct ipc_hdr hdr = { \
.service_id = _service, \
.opcode = _opcode, \
.len = _len, \
} while (0)
struct vardata {
- struct hal_hdr hdr;
- uint8_t buf[BLUEZ_HAL_MTU];
+ struct ipc_hdr hdr;
+ uint8_t buf[IPC_MTU];
} __attribute__((packed));
#define test_datasize_valid(_name, _service, _opcode, _hlen, _addatasize, \
. redundant_data = 666,
};
-struct hal_hdr enable_unknown_service_hdr = {
+struct ipc_hdr enable_unknown_service_hdr = {
.service_id = HAL_SERVICE_ID_MAX + 1,
.opcode = HAL_OP_REGISTER_MODULE,
.len = 0,
};
-struct hal_hdr enable_bt_service_hdr = {
+struct ipc_hdr enable_bt_service_hdr = {
.service_id = HAL_SERVICE_ID_BLUETOOTH,
.opcode = HAL_OP_ENABLE,
.len = 0,
};
struct bt_set_adapter_prop_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_set_adapter_prop prop;
/* data placeholder for hal_cmd_set_adapter_prop.val[0] */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_set_adapter_prop)];
} __attribute__((packed));
};
struct bt_set_remote_prop_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_set_remote_device_prop prop;
/* data placeholder for hal_cmd_set_remote_device_prop.val[0] */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_set_remote_device_prop)];
} __attribute__((packed));
};
struct hidhost_set_info_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_hidhost_set_info info;
/* data placeholder for hal_cmd_hidhost_set_info.descr[0] field */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_hidhost_set_info)];
} __attribute__((packed));
};
struct hidhost_set_report_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_hidhost_set_report report;
/* data placeholder for hal_cmd_hidhost_set_report.data[0] field */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_hidhost_set_report)];
} __attribute__((packed));
};
struct hidhost_send_data_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_hidhost_send_data hiddata;
/* data placeholder for hal_cmd_hidhost_send_data.data[0] field */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_hidhost_send_data)];
} __attribute__((packed));
test_generic("Data size BT Set Adapter Prop Vardata+",
ipc_send_tc, setup, teardown,
&bt_set_adapter_prop_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_adapter_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
test_generic("Data size BT Set Adapter Prop Vardata+",
ipc_send_tc, setup, teardown,
&bt_set_adapter_prop_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_adapter_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
test_generic("Data size BT Set Remote Prop Vardata+",
ipc_send_tc, setup, teardown,
&bt_set_remote_prop_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_remote_device_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
test_generic("Data size BT Set Remote Prop Vardata-",
ipc_send_tc, setup, teardown,
&bt_set_remote_prop_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_remote_device_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
test_generic("Data size HIDHOST Set Info Vardata+",
ipc_send_tc, setup, teardown,
&hidhost_set_info_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_info) +
sizeof(set_info_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Set Info Vardata-",
ipc_send_tc, setup, teardown,
&hidhost_set_info_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_info) +
sizeof(set_info_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Set Report Vardata+",
ipc_send_tc, setup, teardown,
&hidhost_set_report_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_report) +
sizeof(set_rep_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Set Report Vardata-",
ipc_send_tc, setup, teardown,
&hidhost_set_report_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_report) +
sizeof(set_rep_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Send Vardata+",
ipc_send_tc, setup, teardown,
&hidhost_send_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_send_data) +
sizeof(send_data_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Send Vardata-",
ipc_send_tc, setup, teardown,
&hidhost_send_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_send_data) +
sizeof(send_data_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
#include <unistd.h>
#include <glib.h>
-#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "src/log.h"
static int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
const void *buf, ssize_t len)
{
- const struct hal_hdr *msg = buf;
+ const struct ipc_hdr *msg = buf;
const struct ipc_handler *handler;
if (len < (ssize_t) sizeof(*msg)) {
}
/* if opcode is valid */
- if (msg->opcode == HAL_OP_STATUS ||
+ if (msg->opcode == IPC_OP_STATUS ||
msg->opcode > handlers[msg->service_id].size) {
DBG("invalid opcode 0x%x for service 0x%x", msg->opcode,
msg->service_id);
{
struct ipc *ipc = user_data;
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
ssize_t ret;
int fd, err;
{
struct msghdr msg;
struct iovec iv[2];
- struct hal_hdr m;
+ struct ipc_hdr m;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
struct cmsghdr *cmsg;
void ipc_send_rsp(struct ipc *ipc, uint8_t service_id, uint8_t opcode,
uint8_t status)
{
- struct hal_status s;
+ struct ipc_status s;
int sk;
sk = g_io_channel_unix_get_fd(ipc->cmd_io);
- if (status == HAL_STATUS_SUCCESS) {
+ if (status == IPC_STATUS_SUCCESS) {
ipc_send(sk, service_id, opcode, 0, NULL, -1);
return;
}
s.code = status;
- ipc_send(sk, service_id, HAL_OP_STATUS, sizeof(s), &s, -1);
+ ipc_send(sk, service_id, IPC_OP_STATUS, sizeof(s), &s, -1);
}
void ipc_send_rsp_full(struct ipc *ipc, uint8_t service_id, uint8_t opcode,
#include "lib/bluetooth.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "bluetooth.h"
#include "socket.h"
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "utils.h"
#include "bluetooth.h"
#include "src/log.h"
#include "hal-msg.h"
-#include "hal-ipc.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "utils.h"
#include "bluetooth.h"
#include <glib.h>
#include "src/shared/util.h"
#include "src/log.h"
-#include "android/hal-msg.h"
+#include "android/ipc-common.h"
#include "android/ipc.h"
+static const char HAL_SK_PATH[] = "\0test_hal_socket";
+
+#define SERVICE_ID_MAX 10
+
struct test_data {
bool disconnect;
const void *cmd;
{
struct context *context = user_data;
const struct test_data *test_data = context->data;
- const struct hal_hdr *sent_msg = test_data->cmd;
+ const struct ipc_hdr *sent_msg = test_data->cmd;
uint8_t buf[128];
int sk;
- struct hal_hdr success_resp = {
+ struct ipc_hdr success_resp = {
.service_id = sent_msg->service_id,
.opcode = sent_msg->opcode,
.len = 0,
sk = g_io_channel_unix_get_fd(io);
- g_assert(read(sk, buf, sizeof(buf)) == sizeof(struct hal_hdr));
- g_assert(!memcmp(&success_resp, buf, sizeof(struct hal_hdr)));
+ g_assert(read(sk, buf, sizeof(buf)) == sizeof(struct ipc_hdr));
+ g_assert(!memcmp(&success_resp, buf, sizeof(struct ipc_hdr)));
context_quit(context);
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
+ memcpy(addr.sun_path, HAL_SK_PATH, sizeof(HAL_SK_PATH));
ret = bind(sk, (struct sockaddr *) &addr, sizeof(addr));
g_assert(ret == 0);
{
struct context *context = create_context(data);
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, true, NULL, NULL);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX,
+ true, NULL, NULL);
g_assert(ipc);
{
struct context *context = create_context(data);
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, true, disconnected, context);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX,
+ true, disconnected, context);
g_assert(ipc);
struct context *context = create_context(data);
const struct test_data *test_data = context->data;
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, true, disconnected, context);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX,
+ true, disconnected, context);
g_assert(ipc);
{
struct context *context = create_context(data);
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX, true, disconnected, context);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX,
+ true, disconnected, context);
g_assert(ipc);
static const struct test_data test_init_1 = {};
-static const struct hal_hdr test_cmd_1_hdr = {
+static const struct ipc_hdr test_cmd_1_hdr = {
.service_id = 0,
.opcode = 1,
.len = 0
};
-static const struct hal_hdr test_cmd_2_hdr = {
+static const struct ipc_hdr test_cmd_2_hdr = {
.service_id = 0,
.opcode = 2,
.len = 0
#define VARDATA_EX1 "some data example"
struct vardata {
- struct hal_hdr hdr;
- uint8_t data[BLUEZ_HAL_MTU - sizeof(struct hal_hdr)];
+ struct ipc_hdr hdr;
+ uint8_t data[IPC_MTU - sizeof(struct ipc_hdr)];
} __attribute__((packed));
static const struct vardata test_cmd_vardata = {
static const struct test_data test_cmd_vardata_valid = {
.cmd = &test_cmd_vardata,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1),
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1),
.service = 0,
.handlers = cmd_vardata_handlers,
.handlers_size = 1,
static const struct test_data test_cmd_vardata_valid_2 = {
.cmd = &test_cmd_vardata,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1),
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1),
.service = 0,
.handlers = cmd_vardata_handlers_valid2,
.handlers_size = 1,
static const struct test_data test_cmd_vardata_invalid_1 = {
.cmd = &test_cmd_vardata,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1) - 1,
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1) - 1,
.service = 0,
.handlers = cmd_vardata_handlers,
.handlers_size = 1,
.disconnect = true,
};
-static const struct hal_hdr test_cmd_service_offrange_hdr = {
- .service_id = HAL_SERVICE_ID_MAX + 1,
+static const struct ipc_hdr test_cmd_service_offrange_hdr = {
+ .service_id = SERVICE_ID_MAX + 1,
.opcode = 1,
.len = 0
};
static const struct test_data test_cmd_service_offrange = {
.cmd = &test_cmd_service_offrange_hdr,
- .cmd_size = sizeof(struct hal_hdr),
+ .cmd_size = sizeof(struct ipc_hdr),
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
static const struct test_data test_cmd_msg_invalid_1 = {
.cmd = &test_cmd_invalid_data_1,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1) - 1,
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1) - 1,
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
static const struct test_data test_cmd_msg_invalid_2 = {
.cmd = &test_cmd_invalid_data_2,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1),
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1),
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,