• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 
21 #include <log/log.h>
22 
23 #include "packets/link_layer/link_layer_packet_view.h"
24 #include "packets/packet_view.h"
25 
26 namespace test_vendor_lib {
27 namespace packets {
28 
29 class ResponseView : public PacketView<true> {
30  public:
31   ResponseView(const ResponseView&) = default;
32   virtual ~ResponseView() = default;
33 
GetResponse(const LinkLayerPacketView & view)34   static ResponseView GetResponse(const LinkLayerPacketView& view) {
35     CHECK(view.GetType() == Link::PacketType::RESPONSE);
36     return ResponseView(view.GetPayload());
37   }
38 
GetOpcode()39   uint16_t GetOpcode() {
40     return begin().extract<uint16_t>();
41   }
42 
GetResponseData()43   Iterator<true> GetResponseData() {
44     return begin() + sizeof(uint16_t);
45   }
46 
47  private:
48   ResponseView() = delete;
ResponseView(const PacketView<true> & view)49   ResponseView(const PacketView<true>& view) : PacketView(view) {}
50 };
51 
52 }  // namespace packets
53 }  // namespace test_vendor_lib
54