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 #include <string> 23 24 #include "packet/custom_field_fixed_size_interface.h" 25 26 namespace bluetooth { 27 namespace packet { 28 namespace parser { 29 namespace test { 30 31 class SixBytes final : public packet::CustomFieldFixedSizeInterface<SixBytes> { 32 public: 33 static constexpr size_t kLength = 6; 34 35 uint8_t six_bytes[kLength] = {}; 36 37 SixBytes() = default; 38 SixBytes(const uint8_t (&addr)[6]); 39 data()40 inline uint8_t* data() override { 41 return six_bytes; 42 } 43 data()44 inline const uint8_t* data() const override { 45 return six_bytes; 46 } 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 { 52 return (std::memcmp(six_bytes, rhs.six_bytes, sizeof(six_bytes)) == 0); 53 } 54 bool operator>(const SixBytes& rhs) const { 55 return (rhs < *this); 56 } 57 bool operator<=(const SixBytes& rhs) const { 58 return !(*this > rhs); 59 } 60 bool operator>=(const SixBytes& rhs) const { 61 return !(*this < rhs); 62 } 63 bool operator!=(const SixBytes& rhs) const { 64 return !(*this == rhs); 65 } ToString()66 std::string ToString() const { 67 return "SixBytes"; 68 } 69 }; 70 71 } // namespace test 72 } // namespace parser 73 } // namespace packet 74 } // namespace bluetooth 75