Bluetooth: Add MGMT tizen_handlers and TIZEN_OP_BASE_CODE.
authorh.sandeep <h.sandeep@samsung.com>
Thu, 1 Sep 2016 06:30:57 +0000 (12:00 +0530)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 3 Aug 2023 08:43:13 +0000 (17:43 +0900)
Added the basic skeleton code for tizen_mgmt_handlers and
mgmt_tizen.h header file.

Change-Id: I8f3100aa79e6673840ba561f0a9c50238ca0880b
Signed-off-by: h.sandeep <h.sandeep@samsung.com>
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
include/net/bluetooth/hci_core.h
include/net/bluetooth/mgmt_tizen.h [new file with mode: 0644]
net/bluetooth/hci_sock.c
net/bluetooth/mgmt.c

index 3da5cfc..89630a1 100644 (file)
@@ -1753,6 +1753,10 @@ struct hci_mgmt_chan {
        unsigned short channel;
        size_t handler_count;
        const struct hci_mgmt_handler *handlers;
+#ifdef TIZEN_BT
+       size_t tizen_handler_count;
+       const struct hci_mgmt_handler *tizen_handlers;
+#endif
        void (*hdev_init) (struct sock *sk, struct hci_dev *hdev);
 };
 
diff --git a/include/net/bluetooth/mgmt_tizen.h b/include/net/bluetooth/mgmt_tizen.h
new file mode 100644 (file)
index 0000000..6bad3c9
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __MGMT_TIZEN_H
+#define __MGMT_TIZEN_H
+
+#define TIZEN_OP_CODE_BASE     0xff00
+#define TIZEN_EV_BASE          0xff00
+
+#endif /* __MGMT_TIZEN_H */
index f1128c2..d4a3c71 100644 (file)
@@ -33,6 +33,9 @@
 #include <net/bluetooth/hci_core.h>
 #include <net/bluetooth/hci_mon.h>
 #include <net/bluetooth/mgmt.h>
+#ifdef TIZEN_BT
+#include <net/bluetooth/mgmt_tizen.h>
+#endif
 
 #include "mgmt_util.h"
 
@@ -1541,6 +1544,21 @@ static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
                goto done;
        }
 
+#ifdef TIZEN_BT
+       if (opcode >= TIZEN_OP_CODE_BASE) {
+               u16 tizen_opcode_index = opcode - TIZEN_OP_CODE_BASE;
+               if (tizen_opcode_index >= chan->tizen_handler_count ||
+                   chan->tizen_handlers[tizen_opcode_index].func == NULL) {
+                       BT_DBG("Unknown op %u", opcode);
+                       err = mgmt_cmd_status(sk, index, opcode,
+                                             MGMT_STATUS_UNKNOWN_COMMAND);
+                       goto done;
+               }
+
+               handler = &chan->tizen_handlers[tizen_opcode_index];
+
+       } else {
+#endif
        if (chan->channel == HCI_CHANNEL_CONTROL) {
                struct sk_buff *skb;
 
@@ -1563,6 +1581,9 @@ static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
        }
 
        handler = &chan->handlers[opcode];
+#ifdef TIZEN_BT
+       }
+#endif
 
        if (!hci_sock_test_flag(sk, HCI_SOCK_TRUSTED) &&
            !(handler->flags & HCI_MGMT_UNTRUSTED)) {
index 0400049..5a8eb35 100644 (file)
@@ -32,6 +32,9 @@
 #include <net/bluetooth/hci_sock.h>
 #include <net/bluetooth/l2cap.h>
 #include <net/bluetooth/mgmt.h>
+#ifdef TIZEN_BT
+#include <net/bluetooth/mgmt_tizen.h>
+#endif
 
 #include "hci_request.h"
 #include "smp.h"
@@ -8496,6 +8499,12 @@ static const struct hci_mgmt_handler mgmt_handlers[] = {
                                                HCI_MGMT_VAR_LEN },
 };
 
+#ifdef TIZEN_BT
+static const struct hci_mgmt_handler tizen_mgmt_handlers[] = {
+       { NULL }, /* 0x0000 (no command) */
+};
+#endif
+
 void mgmt_index_added(struct hci_dev *hdev)
 {
        struct mgmt_ev_ext_index ev;
@@ -9555,6 +9564,10 @@ static struct hci_mgmt_chan chan = {
        .channel        = HCI_CHANNEL_CONTROL,
        .handler_count  = ARRAY_SIZE(mgmt_handlers),
        .handlers       = mgmt_handlers,
+#ifdef TIZEN_BT
+       .tizen_handler_count    = ARRAY_SIZE(tizen_mgmt_handlers),
+       .tizen_handlers = tizen_mgmt_handlers,
+#endif
        .hdev_init      = mgmt_init_hdev,
 };