network_selector_interface.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Copyright (C) 2016 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. #ifndef UPDATE_ENGINE_NETWORK_SELECTOR_INTERFACE_H_
  17. #define UPDATE_ENGINE_NETWORK_SELECTOR_INTERFACE_H_
  18. #include <cstdint>
  19. namespace chromeos_update_engine {
  20. typedef uint64_t NetworkId;
  21. // A constant value used to indicate the default network id. Defined in the
  22. // network_selector_*.cc file.
  23. extern const NetworkId kDefaultNetworkId;
  24. // A class that handles the network used for the connections performed from this
  25. // process in a platform-specific way.
  26. class NetworkSelectorInterface {
  27. public:
  28. virtual ~NetworkSelectorInterface() = default;
  29. // Set the current process network. All sockets created in the future will be
  30. // bound to this particular network. Call this with the special value
  31. // kNetworkId to use the default network.
  32. virtual bool SetProcessNetwork(NetworkId network_id) = 0;
  33. protected:
  34. NetworkSelectorInterface() = default;
  35. };
  36. } // namespace chromeos_update_engine
  37. #endif // UPDATE_ENGINE_NETWORK_SELECTOR_INTERFACE_H_