2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef NETD_SERVER_NETWORK_H
18 #define NETD_SERVER_NETWORK_H
20 #include "NetdConstants.h"
25 // A Network represents a collection of interfaces participating as a single administrative unit.
35 // You MUST ensure that no interfaces are still assigned to this network, say by calling
36 // clearInterfaces(), before deleting it. This is because interface removal may fail. If we
37 // automatically removed interfaces in the destructor, you wouldn't know if it failed.
40 virtual Type getType() const = 0;
41 unsigned getNetId() const;
43 bool hasInterface(const std::string& interface) const;
44 const std::set<std::string>& getInterfaces() const;
46 // These return 0 on success or negative errno on failure.
47 virtual int addInterface(const std::string& interface) WARN_UNUSED_RESULT = 0;
48 virtual int removeInterface(const std::string& interface) WARN_UNUSED_RESULT = 0;
49 int clearInterfaces() WARN_UNUSED_RESULT;
51 std::string toString() const;
54 explicit Network(unsigned netId);
56 const unsigned mNetId;
57 std::set<std::string> mInterfaces;
60 #endif // NETD_SERVER_NETWORK_H