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