1 /****************************************************************************** 2 * 3 * Copyright 2019 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #pragma once 20 21 #include <stdint.h> 22 23 #include <string> 24 25 #include "packet/custom_field_fixed_size_interface.h" 26 27 namespace bluetooth { 28 namespace packet { 29 namespace parser { 30 namespace test { 31 32 class SixBytes final : public packet::CustomFieldFixedSizeInterface<SixBytes> { 33 public: 34 static constexpr size_t kLength = 6; 35 36 uint8_t six_bytes[kLength] = {}; 37 38 SixBytes() = default; 39 SixBytes(const uint8_t (&addr)[6]); 40 data()41 inline uint8_t* data() override { return six_bytes; } 42 data()43 inline const uint8_t* data() const override { return six_bytes; } 44 45 bool operator<(const SixBytes& rhs) const { 46 return std::memcmp(six_bytes, rhs.six_bytes, sizeof(six_bytes)) < 0; 47 } 48 bool operator==(const SixBytes& rhs) const { 49 return std::memcmp(six_bytes, rhs.six_bytes, sizeof(six_bytes)) == 0; 50 } 51 bool operator>(const SixBytes& rhs) const { return rhs < *this; } 52 bool operator<=(const SixBytes& rhs) const { return !(*this > rhs); } 53 bool operator>=(const SixBytes& rhs) const { return !(*this < rhs); } 54 bool operator!=(const SixBytes& rhs) const { return !(*this == rhs); } ToString()55 std::string ToString() const { return "SixBytes"; } 56 }; 57 58 } // namespace test 59 } // namespace parser 60 } // namespace packet 61 } // namespace bluetooth 62