l2test: Add support for BT_MODE_EXT_FLOWCTL
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 2 Aug 2019 07:44:43 +0000 (10:44 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:48 +0000 (14:30 +0530)
This enables using l2test to connect or listen with
BT_MODE_EXT_FLOWCTL.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/l2test.c

index 835ff4b..8f751e8 100755 (executable)
@@ -153,13 +153,14 @@ struct lookup_table {
 };
 
 static struct lookup_table l2cap_modes[] = {
-       { "basic",      L2CAP_MODE_BASIC        },
+       { "basic",      BT_MODE_BASIC           },
        /* Not implemented
-       { "flowctl",    L2CAP_MODE_FLOWCTL      },
-       { "retrans",    L2CAP_MODE_RETRANS      },
+       { "flowctl",    BT_MODE_FLOWCTL         },
+       { "retrans",    BT_MODE_RETRANS         },
        */
-       { "ertm",       L2CAP_MODE_ERTM         },
-       { "streaming",  L2CAP_MODE_STREAMING    },
+       { "ertm",       BT_MODE_ERTM            },
+       { "streaming",  BT_MODE_STREAMING       },
+       { "ext-flowctl", BT_MODE_EXT_FLOWCTL    },
        { 0 }
 };
 
@@ -293,7 +294,7 @@ static int getopts(int sk, struct l2cap_options *opts, bool connected)
 
        memset(opts, 0, sizeof(*opts));
 
-       if (bdaddr_type == BDADDR_BREDR) {
+       if (bdaddr_type == BDADDR_BREDR || rfcmode) {
                optlen = sizeof(*opts);
                return getsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, opts, &optlen);
        }
@@ -313,6 +314,13 @@ static int setopts(int sk, struct l2cap_options *opts)
                return setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, opts,
                                                                sizeof(*opts));
 
+       if (opts->mode) {
+               if (setsockopt(sk, SOL_BLUETOOTH, BT_MODE, &opts->mode,
+                                               sizeof(opts->mode)) < 0) {
+                       return -errno;
+               }
+       }
+
        return setsockopt(sk, SOL_BLUETOOTH, BT_RCVMTU, &opts->imtu,
                                                        sizeof(opts->imtu));
 }