Options.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. *
  3. * Copyright (c) 2020 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. /**
  19. * @file
  20. * Support functions for parsing command-line arguments.
  21. *
  22. */
  23. #pragma once
  24. #include <cstdint>
  25. #include <string>
  26. #include <vector>
  27. #include <inet/InetInterface.h>
  28. #include <lib/core/CHIPError.h>
  29. #include <lib/core/Optional.h>
  30. #include <lib/support/CHIPArgParser.hpp>
  31. #include <platform/CHIPDeviceConfig.h>
  32. #include <setup_payload/SetupPayload.h>
  33. #include <credentials/DeviceAttestationCredsProvider.h>
  34. #include <testing/CustomCSRResponse.h>
  35. struct LinuxDeviceOptions
  36. {
  37. chip::PayloadContents payload;
  38. chip::Optional<uint16_t> discriminator;
  39. chip::Optional<std::vector<uint8_t>> spake2pVerifier;
  40. chip::Optional<std::vector<uint8_t>> spake2pSalt;
  41. uint32_t spake2pIterations = 0; // When not provided (0), will default elsewhere
  42. uint32_t mBleDevice = 0;
  43. bool mWiFi = false;
  44. bool mThread = false;
  45. #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS
  46. uint16_t securedDevicePort = CHIP_PORT;
  47. uint16_t unsecuredCommissionerPort = CHIP_UDC_PORT;
  48. #endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
  49. #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
  50. uint16_t securedCommissionerPort = CHIP_PORT + 12; // TODO: why + 12?
  51. #endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
  52. const char * command = nullptr;
  53. const char * PICS = nullptr;
  54. const char * KVS = nullptr;
  55. chip::Inet::InterfaceId interfaceId = chip::Inet::InterfaceId::Null();
  56. bool traceStreamDecodeEnabled = false;
  57. bool traceStreamToLogEnabled = false;
  58. chip::Optional<std::string> traceStreamFilename;
  59. chip::Credentials::DeviceAttestationCredentialsProvider * dacProvider = nullptr;
  60. chip::CSRResponseOptions mCSRResponseOptions;
  61. uint8_t testEventTriggerEnableKey[16] = { 0 };
  62. chip::FabricId commissionerFabricId = chip::kUndefinedFabricId;
  63. std::vector<std::string> traceTo;
  64. bool mSimulateNoInternalTime = false;
  65. static LinuxDeviceOptions & GetInstance();
  66. };
  67. CHIP_ERROR ParseArguments(int argc, char * const argv[], chip::ArgParser::OptionSet * customOptions = nullptr);