2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <gio/gunixfdlist.h>
22 #include <sys/socket.h>
25 #include "bluetooth-api.h"
26 #include "bt-internal-types.h"
28 #include "bt-common.h"
29 #include "bt-request-sender.h"
30 #include "bt-event-handler.h"
32 #ifdef TIZEN_DPM_ENABLE
38 static GSList *rfcomm_nodes;
48 bluetooth_device_address_t addr;
49 guint disconnect_idle_id;
52 static rfcomm_info_t *__find_rfcomm_info_with_id(int id)
56 for (l = rfcomm_nodes; l != NULL; l = l->next) {
57 rfcomm_info_t *info = l->data;
66 static rfcomm_info_t *__find_rfcomm_info_with_fd(int fd)
70 for (l = rfcomm_nodes; l != NULL; l = l->next) {
71 rfcomm_info_t *info = l->data;
80 static rfcomm_info_t *__find_rfcomm_info_with_path(const gchar *path)
84 for (l = rfcomm_nodes; l != NULL; l = l->next) {
85 rfcomm_info_t *info = l->data;
87 if (g_strcmp0(info->path, path) == 0)
94 static rfcomm_info_t *__find_rfcomm_info_with_uuid(const char *uuid)
98 for (l = rfcomm_nodes; l != NULL; l = l->next) {
99 rfcomm_info_t *info = l->data;
101 if (g_strcmp0(info->uuid, uuid) == 0)
108 gboolean _check_uuid_path(char *path, char *uuid)
110 rfcomm_info_t *info = NULL;
111 info = __find_rfcomm_info_with_path(path);
115 if (strcmp(info->uuid, uuid) == 0)
121 static void __connected_cb(rfcomm_info_t *info, bt_event_info_t *event_info)
123 bluetooth_rfcomm_connection_t conn_info;
125 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
126 conn_info.device_role = RFCOMM_ROLE_SERVER;
127 g_strlcpy(conn_info.uuid, info->uuid, BLUETOOTH_UUID_STRING_MAX);
128 conn_info.socket_fd = info->fd;
129 conn_info.device_addr = info->addr;
130 conn_info.server_id = info->id;
132 BT_INFO_C("Connected [RFCOMM Server]");
133 _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_CONNECTED,
134 BLUETOOTH_ERROR_NONE, &conn_info,
135 event_info->cb, event_info->user_data);
138 static gboolean __rfcomm_server_disconnect(rfcomm_info_t *info)
140 bluetooth_rfcomm_disconnection_t disconn_info;
142 bt_event_info_t *event_info;
144 BT_INFO_C("Disconnected [RFCOMM Server]");
146 if (info->data_id > 0) {
147 g_source_remove(info->data_id);
157 g_io_channel_shutdown(info->data_io, TRUE, NULL);
158 g_io_channel_unref(info->data_io);
159 info->data_io = NULL;
161 info->disconnect_idle_id = 0;
162 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
163 if (event_info == NULL)
166 memset(&disconn_info, 0x00, sizeof(bluetooth_rfcomm_disconnection_t));
167 disconn_info.device_role = RFCOMM_ROLE_SERVER;
168 g_strlcpy(disconn_info.uuid, info->uuid, BLUETOOTH_UUID_STRING_MAX);
169 disconn_info.socket_fd = fd;
170 disconn_info.device_addr = info->addr;
172 _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,
173 BLUETOOTH_ERROR_NONE, &disconn_info,
174 event_info->cb, event_info->user_data);
180 static gboolean __data_received_cb(GIOChannel *chan, GIOCondition cond,
185 int result = BLUETOOTH_ERROR_NONE;
186 rfcomm_info_t *info = data;
187 bt_event_info_t *event_info;
188 bluetooth_rfcomm_received_data_t data_r;
189 GIOStatus status = G_IO_STATUS_NORMAL;
192 retv_if(info == NULL, FALSE);
194 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
196 if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
197 BT_ERR_C("RFComm Server disconnected: %d", info->fd);
199 if (info->disconnect_idle_id > 0) {
200 BT_INFO("Disconnect idle still not process remove source");
201 g_source_remove(info->disconnect_idle_id);
202 info->disconnect_idle_id = 0;
205 __rfcomm_server_disconnect(info);
209 buffer = g_malloc0(BT_RFCOMM_BUFFER_LEN + 1);
211 status = g_io_channel_read_chars(chan, buffer, BT_RFCOMM_BUFFER_LEN,
213 if (status != G_IO_STATUS_NORMAL) {
214 BT_ERR("IO Channel read is failed with %d", status);
218 BT_ERR("IO Channel read error [%s]", err->message);
219 if (status == G_IO_STATUS_ERROR &&
220 !g_strcmp0(err->message, "Connection reset by peer")) {
221 BT_ERR("cond : %d", cond);
223 if (info->disconnect_idle_id > 0) {
224 BT_INFO("Disconnect idle still not process remove source");
225 g_source_remove(info->disconnect_idle_id);
226 info->disconnect_idle_id = 0;
228 __rfcomm_server_disconnect(info);
237 BT_ERR("Length is zero");
239 if (event_info == NULL) {
244 data_r.socket_fd = info->fd;
245 data_r.buffer_size = len;
246 data_r.buffer = buffer;
248 _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED,
250 event_info->cb, event_info->user_data);
257 int new_server_connection(const char *path, int fd, bluetooth_device_address_t *addr)
260 bt_event_info_t *event_info;
262 BT_DBG("%s %d", path, fd);
264 info = __find_rfcomm_info_with_path(path);
269 memcpy(&info->addr, addr, sizeof(bluetooth_device_address_t));
271 info->data_io = g_io_channel_unix_new(info->fd);
273 g_io_channel_set_encoding(info->data_io, NULL, NULL);
274 g_io_channel_set_flags(info->data_io, G_IO_FLAG_NONBLOCK, NULL);
276 info->data_id = g_io_add_watch(info->data_io,
277 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
278 __data_received_cb, info);
280 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
282 __connected_cb(info, event_info);
288 static rfcomm_info_t *__register_method()
295 id = __rfcomm_assign_id();
299 path = g_strdup_printf("/org/socket/server/%d/%d", getpid(), id);
301 object_id = _bt_register_new_conn(path, new_server_connection);
303 __rfcomm_delete_id(id);
306 info = g_new(rfcomm_info_t, 1);
307 info->object_id = (guint)object_id;
312 rfcomm_nodes = g_slist_append(rfcomm_nodes, info);
317 static rfcomm_info_t *__register_method_2(const char *path,const char *bus_name)
322 object_id = _bt_register_new_conn_ex(path, bus_name, new_server_connection);
326 info = g_new(rfcomm_info_t, 1);
327 info->object_id = (guint)object_id;
328 info->path = g_strdup(path);
332 rfcomm_nodes = g_slist_append(rfcomm_nodes, info);
337 void free_rfcomm_info(rfcomm_info_t *info)
339 bt_event_info_t *event_info;
342 if (info->disconnect_idle_id > 0) {
343 BT_INFO("Disconnect idle still not process remove source");
344 g_source_remove(info->disconnect_idle_id);
345 info->disconnect_idle_id = 0;
348 __rfcomm_delete_id(info->id);
349 _bt_unregister_gdbus(info->object_id);
352 event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
354 BT_DBG("event type %d", event_info->event_type);
355 __rfcomm_server_disconnect(info);
363 void _bt_rfcomm_server_free_all()
365 BT_DBG("Free all the servers");
367 g_slist_free_full(rfcomm_nodes, (GDestroyNotify)free_rfcomm_info);
372 BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid)
379 char uuid_str[BLUETOOTH_UUID_STRING_MAX];
382 BT_CHECK_ENABLED(return);
383 BT_CHECK_PARAMETER(uuid, return);
384 BT_INFO("UUID Provided %s", uuid);
386 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET)
387 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
388 BT_ERR("Don't have a privilege to use this API");
389 return BLUETOOTH_ERROR_PERMISSION_DEINED;
392 #ifdef TIZEN_DPM_ENABLE
393 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
394 BT_ERR("Not allow to use SPP profile");
395 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
400 BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
401 info = __register_method();
405 info->uuid = g_strdup(uuid);
406 info->disconnect_idle_id = 0;
411 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
413 g_strlcpy(uuid_str, uuid, sizeof(uuid_str));
414 g_array_append_vals(in_param1, uuid_str, BLUETOOTH_UUID_STRING_MAX);
416 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET,
417 in_param1, in_param2, in_param3, in_param4, &out_param);
419 BT_DBG("result: %x", result);
421 if (result == BLUETOOTH_ERROR_NONE) {
422 socket_fd = g_array_index(out_param, int, 0);
424 BT_ERR("Fail to send request");
427 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
433 BT_EXPORT_API int bluetooth_rfcomm_create_socket_ex(const char *uuid, const char *bus_name, const char *path)
438 BT_CHECK_ENABLED(return);
439 BT_CHECK_PARAMETER(path, return);
440 BT_INFO("PATH Provided %s", path);
442 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET_EX)
443 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
444 BT_ERR("Don't have a privilege to use this API");
445 return BLUETOOTH_ERROR_PERMISSION_DEINED;
448 #ifdef TIZEN_DPM_ENABLE
449 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
450 BT_ERR("Not allow to use SPP profile");
451 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
455 BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
456 info = __register_method_2(path, bus_name);
458 return BLUETOOTH_ERROR_IN_PROGRESS;
459 info->uuid = g_strdup(uuid);
460 info->disconnect_idle_id = 0;
462 return BLUETOOTH_ERROR_NONE;
464 return BLUETOOTH_ERROR_NOT_SUPPORT;
469 BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd)
477 BT_CHECK_ENABLED(return);
479 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET)
480 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
481 BT_ERR("Don't have a privilege to use this API");
482 return BLUETOOTH_ERROR_PERMISSION_DEINED;
486 BT_ERR("Invalid FD");
487 return BLUETOOTH_ERROR_INVALID_PARAM;
491 BT_INFO("<<<<<<<<< RFCOMM Remove socket request from app, fd=[%d] >>>>>>>>>>>", socket_fd);
493 info = __find_rfcomm_info_with_id(socket_fd);
495 return BLUETOOTH_ERROR_INVALID_PARAM;
497 _bt_unregister_osp_server_in_agent(BT_RFCOMM_SERVER,info->uuid);
498 _bt_unregister_profile(info->path);
500 rfcomm_nodes = g_slist_remove(rfcomm_nodes, info);
501 free_rfcomm_info(info);
503 return BLUETOOTH_ERROR_NONE;
506 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
508 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
510 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET,
511 in_param1, in_param2, in_param3, in_param4, &out_param);
513 BT_DBG("result: %x", result);
515 if (result == BLUETOOTH_ERROR_NONE) {
516 _bt_remove_server(socket_fd);
519 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
525 BT_EXPORT_API int bluetooth_rfcomm_remove_socket_ex(const char *uuid)
530 BT_CHECK_ENABLED(return);
532 if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET)
533 == BLUETOOTH_ERROR_PERMISSION_DEINED) {
534 BT_ERR("Don't have a privilege to use this API");
535 return BLUETOOTH_ERROR_PERMISSION_DEINED;
538 BT_INFO("<<<<<<<<< RFCOMM Remove socket request from app, uuid=[%s] >>>>>>>>>>>", uuid);
540 info = __find_rfcomm_info_with_uuid(uuid);
542 return BLUETOOTH_ERROR_INVALID_PARAM;
544 _bt_unregister_osp_server_in_agent(BT_RFCOMM_SERVER, info->uuid);
545 _bt_unregister_profile(info->path);
547 rfcomm_nodes = g_slist_remove(rfcomm_nodes, info);
548 free_rfcomm_info(info);
550 return BLUETOOTH_ERROR_NONE;
552 return BLUETOOTH_ERROR_NOT_SUPPORT;
556 BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
563 BT_INFO(">>>>>>>>RFCOMM server disconnect request from APP>>>>>>>>>");
565 BT_ERR("Invalid FD");
566 return BLUETOOTH_ERROR_INVALID_PARAM;
569 info = __find_rfcomm_info_with_fd(socket_fd);
571 return BLUETOOTH_ERROR_INVALID_PARAM;
573 if (info->data_io == NULL)
574 return BLUETOOTH_ERROR_NOT_CONNECTED;
576 g_io_channel_shutdown(info->data_io, TRUE, NULL);
577 g_io_channel_unref(info->data_io);
578 info->data_io = NULL;
580 _bt_convert_addr_type_to_string(address, info->addr.addr);
581 BT_DBG("Address %s", address);
582 _bt_disconnect_profile(address, info->uuid, NULL,NULL);
584 info->disconnect_idle_id = g_idle_add((GSourceFunc)
585 __rfcomm_server_disconnect, info);
588 return BLUETOOTH_ERROR_NONE;
592 BT_CHECK_ENABLED(return);
595 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
597 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
599 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_SOCKET_DISCONNECT,
600 in_param1, in_param2, in_param3, in_param4, &out_param);
602 BT_DBG("result: %x", result);
604 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
610 BT_EXPORT_API gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid)
613 gboolean available = TRUE;
614 char uuid_str[BLUETOOTH_UUID_STRING_MAX];
616 retv_if(uuid == NULL, FALSE);
617 retv_if(bluetooth_check_adapter() ==
618 BLUETOOTH_ADAPTER_DISABLED, FALSE);
621 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
623 g_strlcpy(uuid_str, uuid, sizeof(uuid_str));
624 g_array_append_vals(in_param1, uuid_str, BLUETOOTH_UUID_STRING_MAX);
626 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_IS_UUID_AVAILABLE,
627 in_param1, in_param2, in_param3, in_param4, &out_param);
629 BT_DBG("result: %x", result);
631 if (result == BLUETOOTH_ERROR_NONE) {
632 available = g_array_index(out_param, gboolean, 0);
635 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
637 BT_DBG("available: %d", available);
642 BT_EXPORT_API int bluetooth_rfcomm_server_is_connected(const bluetooth_device_address_t *device_address, gboolean *connected)
646 char connected_addr[BT_ADDRESS_STRING_SIZE] = { 0 };
647 char input_addr[BT_ADDRESS_STRING_SIZE] = { 0 };
649 BT_CHECK_PARAMETER(device_address, return);
650 BT_CHECK_PARAMETER(connected, return);
652 _bt_convert_addr_type_to_string(input_addr, (unsigned char *)device_address->addr);
656 for (l = rfcomm_nodes; l != NULL; l = l->next) {
661 _bt_convert_addr_type_to_string(connected_addr, info->addr.addr);
663 if (g_strcmp0(connected_addr, input_addr) == 0) {
665 return BLUETOOTH_ERROR_NONE;
669 return BLUETOOTH_ERROR_NONE;
672 BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection)
678 gboolean native_service = TRUE;
681 BT_CHECK_ENABLED(return);
683 #ifdef TIZEN_DPM_ENABLE
684 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
685 BT_ERR("Not allow to use SPP profile");
686 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
691 BT_ERR("Invalid FD");
692 return BLUETOOTH_ERROR_INVALID_PARAM;
696 BT_INFO("<<<<<<<<< RFCOMM Listen & accept from app >>>>>>>>>>>");
698 info = __find_rfcomm_info_with_id(socket_fd);
700 return BLUETOOTH_ERROR_INVALID_PARAM;
702 bt_register_profile_info_t profile_info;
705 profile_info.authentication = TRUE;
706 profile_info.authorization = TRUE;
707 profile_info.obj_path = info->path;
708 profile_info.role = NULL;
709 profile_info.service = info->uuid;
710 profile_info.uuid = info->uuid;
712 BT_INFO("uuid %s", profile_info.uuid);
713 result = _bt_register_profile(&profile_info, TRUE);
718 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
720 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
721 g_array_append_vals(in_param2, &max_pending_connection, sizeof(int));
722 g_array_append_vals(in_param3, &native_service, sizeof(gboolean));
724 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
725 in_param1, in_param2, in_param3, in_param4, &out_param);
727 BT_DBG("result: %x", result);
729 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
735 BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept_ex(const char *uuid, int max_pending_connection, const char *bus_name, const char *path)
740 BT_CHECK_ENABLED(return);
742 #ifdef TIZEN_DPM_ENABLE
743 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
744 BT_ERR("Not allow to use SPP profile");
745 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
749 BT_INFO("<<<<<<<<< RFCOMM Listen & accept from app >>>>>>>>>>>");
751 info = __find_rfcomm_info_with_uuid(uuid);
753 return BLUETOOTH_ERROR_INVALID_PARAM;
755 bt_register_profile_info_t profile_info;
758 profile_info.authentication = TRUE;
759 profile_info.authorization = TRUE;
760 profile_info.obj_path = info->path;
761 profile_info.role = NULL;
762 profile_info.service = info->uuid;
763 profile_info.uuid = info->uuid;
765 BT_INFO("uuid %s", profile_info.uuid);
766 result = _bt_register_profile_ex(&profile_info, TRUE, bus_name, path);
770 return BLUETOOTH_ERROR_NOT_SUPPORT;
774 BT_EXPORT_API int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection)
780 gboolean native_service = FALSE;
783 BT_CHECK_ENABLED(return);
785 #ifdef TIZEN_DPM_ENABLE
786 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
787 BT_ERR("Not allow to use SPP profile");
788 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
793 BT_ERR("Invalid FD");
794 return BLUETOOTH_ERROR_INVALID_PARAM;
798 BT_INFO("<<<<<<<<< RFCOMM Listen >>>>>>>>>>>");
800 info = __find_rfcomm_info_with_id(socket_fd);
802 return BLUETOOTH_ERROR_INVALID_PARAM;
804 bt_register_profile_info_t profile_info;
807 profile_info.authentication = TRUE;
808 profile_info.authorization = TRUE;
809 profile_info.obj_path = info->path;
810 profile_info.role = NULL;
811 profile_info.service = info->uuid;
812 profile_info.uuid = info->uuid;
813 BT_INFO("UUID %s", info->uuid);
814 BT_INFO("PATH %s", info->path);
815 result = _bt_register_profile_platform(&profile_info, TRUE);
816 if (result != BLUETOOTH_ERROR_NONE)
819 return _bt_register_osp_server_in_agent(BT_RFCOMM_SERVER, info->uuid,
820 info->path, socket_fd);
824 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
826 g_array_append_vals(in_param1, &socket_fd, sizeof(int));
827 g_array_append_vals(in_param2, &max_pending_connection, sizeof(int));
828 g_array_append_vals(in_param3, &native_service, sizeof(gboolean));
830 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_LISTEN,
831 in_param1, in_param2, in_param3, in_param4, &out_param);
833 BT_DBG("result: %x", result);
835 if (result == BLUETOOTH_ERROR_NONE) {
836 _bt_add_server(socket_fd);
839 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
845 BT_EXPORT_API int bluetooth_rfcomm_accept_connection(int server_fd)
849 BT_CHECK_ENABLED(return);
851 #ifdef TIZEN_DPM_ENABLE
852 if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
853 BT_ERR("Not allow to use SPP profile");
854 return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
859 BT_ERR("Invalid FD");
860 return BLUETOOTH_ERROR_INVALID_PARAM;
864 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
866 g_array_append_vals(in_param1, &server_fd, sizeof(int));
868 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_ACCEPT_CONNECTION,
869 in_param1, in_param2, in_param3, in_param4, &out_param);
871 BT_DBG("result: %x", result);
873 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
878 BT_EXPORT_API int bluetooth_rfcomm_reject_connection(int server_fd)
882 BT_CHECK_ENABLED(return);
885 BT_ERR("Invalid FD");
886 return BLUETOOTH_ERROR_INVALID_PARAM;
892 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
894 g_array_append_vals(in_param1, &server_fd, sizeof(int));
896 result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_REJECT_CONNECTION,
897 in_param1, in_param2, in_param3, in_param4, &out_param);
899 BT_DBG("result: %x", result);
901 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);