• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 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 #pragma once
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "base/logging.h"
23 
24 #include "packets/packet_builder.h"
25 
26 namespace test_vendor_lib {
27 namespace packets {
28 
29 class IoCapabilityBuilder : public PacketBuilder<true> {
30  public:
31   virtual ~IoCapabilityBuilder() = default;
32 
Create(uint8_t io_capability,uint8_t oob_data_present,uint8_t authentication_requirements)33   static std::unique_ptr<IoCapabilityBuilder> Create(uint8_t io_capability, uint8_t oob_data_present,
34                                                      uint8_t authentication_requirements) {
35     return std::unique_ptr<IoCapabilityBuilder>(
36         new IoCapabilityBuilder(io_capability, oob_data_present, authentication_requirements));
37   }
38 
size()39   virtual size_t size() const override {
40     return sizeof(io_capability_) + sizeof(oob_data_present_) + sizeof(authentication_requirements_);
41   }
42 
43  protected:
Serialize(std::back_insert_iterator<std::vector<uint8_t>> it)44   virtual void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override {
45     insert(io_capability_, it);
46     insert(oob_data_present_, it);
47     insert(authentication_requirements_, it);
48   }
49 
50  private:
IoCapabilityBuilder(uint8_t io_capability,uint8_t oob_data_present,uint8_t authentication_requirements)51   explicit IoCapabilityBuilder(uint8_t io_capability, uint8_t oob_data_present, uint8_t authentication_requirements)
52       : io_capability_(io_capability), oob_data_present_(oob_data_present),
53         authentication_requirements_(authentication_requirements) {}
54   uint8_t io_capability_;
55   uint8_t oob_data_present_;
56   uint8_t authentication_requirements_;
57 };
58 
59 }  // namespace packets
60 }  // namespace test_vendor_lib
61