• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #include "hci/fuzz/status_vs_complete_commands.h"
18 
19 #include <map>
20 
21 namespace bluetooth {
22 namespace hci {
23 namespace fuzz {
24 
25 using ::bluetooth::hci::OpCode;
26 
27 constexpr OpCode StatusOpCodes[] = {
28         OpCode::RESET,
29 };
30 
31 static std::map<OpCode, bool> commands_that_use_status;
32 
maybe_populate_list()33 static void maybe_populate_list() {
34   if (!commands_that_use_status.empty()) {
35     return;
36   }
37 
38   for (OpCode code : StatusOpCodes) {
39     commands_that_use_status[code] = true;
40   }
41 }
42 
uses_command_status(OpCode code)43 bool uses_command_status(OpCode code) {
44   maybe_populate_list();
45   return commands_that_use_status.find(code) != commands_that_use_status.end();
46 }
47 
uses_command_status_or_complete(OpCode code)48 bool uses_command_status_or_complete(OpCode code) {
49   bool is_vendor_specific = (static_cast<int>(code) >> 10) == 0x3f;
50   return is_vendor_specific;
51 }
52 
53 }  // namespace fuzz
54 }  // namespace hci
55 }  // namespace bluetooth
56