Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3dfd5a76 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Add extractBE to the Bluetooth Packets Iterators

ExtractBE allows data to be extracted from Bluetooth packets in a big
endian format.

Bug: 114751344
Test: run net_test_btpackets
Change-Id: Ib01d726893e106d34c11048acc09fee201d81c09
parent 70f9d810
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ BrowsePdu BrowsePacket::GetPdu() const {

uint16_t BrowsePacket::GetLength() const {
  auto it = begin() + static_cast<size_t>(1);
  return base::ByteSwap(it.extract<uint16_t>());
  return it.extractBE<uint16_t>();
}

bool BrowsePacket::IsValid() const {
+3 −3
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ bool ChangePathResponseBuilder::Serialize(

uint16_t ChangePathRequest::GetUidCounter() const {
  auto it = begin() + BrowsePacket::kMinSize();
  return base::ByteSwap(it.extract<uint16_t>());
  return it.extractBE<uint16_t>();
}

Direction ChangePathRequest::GetDirection() const {
@@ -62,7 +62,7 @@ Direction ChangePathRequest::GetDirection() const {

uint64_t ChangePathRequest::GetUid() const {
  auto it = begin() + BrowsePacket::kMinSize() + static_cast<size_t>(3);
  return base::ByteSwap(it.extract<uint64_t>());
  return it.extractBE<uint64_t>();
}

bool ChangePathRequest::IsValid() const {
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ std::vector<Attribute> GetElementAttributesRequest::GetAttributesRequested()
  std::vector<Attribute> attribute_list;

  for (size_t i = 0; i < number_of_attributes; i++) {
    attribute_list.push_back((Attribute)base::ByteSwap(it.extract<uint32_t>()));
    attribute_list.push_back((Attribute)it.extractBE<uint32_t>());
  }

  return attribute_list;
+4 −4
Original line number Diff line number Diff line
@@ -236,12 +236,12 @@ Scope GetFolderItemsRequest::GetScope() const {

uint32_t GetFolderItemsRequest::GetStartItem() const {
  auto it = begin() + BrowsePacket::kMinSize() + static_cast<size_t>(1);
  return base::ByteSwap(it.extract<uint32_t>());
  return it.extractBE<uint32_t>();
}

uint32_t GetFolderItemsRequest::GetEndItem() const {
  auto it = begin() + BrowsePacket::kMinSize() + static_cast<size_t>(5);
  return base::ByteSwap(it.extract<uint32_t>());
  return it.extractBE<uint32_t>();
}

uint8_t GetFolderItemsRequest::GetNumAttributes() const {
@@ -263,7 +263,7 @@ std::vector<Attribute> GetFolderItemsRequest::GetAttributesRequested() const {
  // to have this function return a vector with all the attributes

  for (size_t i = 0; i < number_of_attributes; i++) {
    attribute_list.push_back((Attribute)base::ByteSwap(it.extract<uint32_t>()));
    attribute_list.push_back((Attribute)it.extractBE<uint32_t>());
  }

  return attribute_list;
+4 −4
Original line number Diff line number Diff line
@@ -91,12 +91,12 @@ Scope GetItemAttributesRequest::GetScope() const {

uint64_t GetItemAttributesRequest::GetUid() const {
  auto it = begin() + BrowsePacket::kMinSize() + static_cast<size_t>(1);
  return base::ByteSwap(it.extract<uint64_t>());
  return it.extractBE<uint64_t>();
}

uint16_t GetItemAttributesRequest::GetUidCounter() const {
  auto it = begin() + BrowsePacket::kMinSize() + static_cast<size_t>(9);
  return base::ByteSwap(it.extract<uint16_t>());
  return it.extractBE<uint16_t>();
}

uint8_t GetItemAttributesRequest::GetNumAttributes() const {
@@ -111,7 +111,7 @@ std::vector<Attribute> GetItemAttributesRequest::GetAttributesRequested()

  std::vector<Attribute> attribute_list;
  for (size_t i = 0; i < number_of_attributes; i++) {
    attribute_list.push_back((Attribute)base::ByteSwap(it.extract<uint32_t>()));
    attribute_list.push_back((Attribute)it.extractBE<uint32_t>());
  }

  return attribute_list;
Loading