logging_utils.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C) 2017 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. #include "wificond/logging_utils.h"
  17. #include <array>
  18. #include <iomanip>
  19. #include <android-base/macros.h>
  20. using std::array;
  21. using std::string;
  22. using std::stringstream;
  23. namespace android {
  24. namespace wificond {
  25. string LoggingUtils::GetMacString(const array<uint8_t, ETH_ALEN>& mac_address) {
  26. stringstream ss;
  27. for (const uint8_t& b : mac_address) {
  28. ss << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(b);
  29. if (&b != &mac_address.back()) {
  30. ss << ":";
  31. }
  32. }
  33. return ss.str();
  34. }
  35. string LoggingUtils::GetBandwidthString(ChannelBandwidth bandwidth) {
  36. switch (bandwidth) {
  37. case BW_20_NOHT:
  38. return "20MHz no HT";
  39. case BW_20:
  40. return "20MHz with HT";
  41. case BW_40:
  42. return "40MHz";
  43. case BW_80:
  44. return "80MHz";
  45. case BW_80P80:
  46. return "80+80MHz";
  47. case BW_160:
  48. return "160MHz";
  49. default:
  50. return "Invalid";
  51. }
  52. return "Invalid";
  53. }
  54. } // namespace wificond
  55. } // namespace android