Sreeram Ramachandran | b1425cc | 2014-06-23 18:54:27 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 NETD_SERVER_UID_RANGES_H |
| 18 | #define NETD_SERVER_UID_RANGES_H |
| 19 | |
Luke Huang | 94658ac | 2018-10-18 19:35:12 +0900 | [diff] [blame] | 20 | #include "android/net/INetd.h" |
Robin Lee | 9f9aae9 | 2016-03-30 18:33:07 +0100 | [diff] [blame] | 21 | |
Sreeram Ramachandran | b1425cc | 2014-06-23 18:54:27 -0700 | [diff] [blame] | 22 | #include <sys/types.h> |
| 23 | #include <utility> |
| 24 | #include <vector> |
| 25 | |
Lorenzo Colitti | 7035f22 | 2017-02-13 18:29:00 +0900 | [diff] [blame] | 26 | namespace android { |
| 27 | namespace net { |
| 28 | |
Sreeram Ramachandran | b1425cc | 2014-06-23 18:54:27 -0700 | [diff] [blame] | 29 | class UidRanges { |
| 30 | public: |
Lorenzo Colitti | 563d98b | 2016-04-24 13:13:14 +0900 | [diff] [blame] | 31 | UidRanges() {} |
Luke Huang | 94658ac | 2018-10-18 19:35:12 +0900 | [diff] [blame] | 32 | UidRanges(const std::vector<android::net::UidRangeParcel>& ranges); |
Lorenzo Colitti | 563d98b | 2016-04-24 13:13:14 +0900 | [diff] [blame] | 33 | |
Sreeram Ramachandran | e09b20a | 2014-07-05 17:15:14 -0700 | [diff] [blame] | 34 | bool hasUid(uid_t uid) const; |
Luke Huang | 94658ac | 2018-10-18 19:35:12 +0900 | [diff] [blame] | 35 | const std::vector<UidRangeParcel>& getRanges() const; |
Sreeram Ramachandran | b1425cc | 2014-06-23 18:54:27 -0700 | [diff] [blame] | 36 | |
| 37 | bool parseFrom(int argc, char* argv[]); |
Lorenzo Colitti | fff4bd3 | 2016-04-14 00:56:01 +0900 | [diff] [blame] | 38 | std::string toString() const; |
Sreeram Ramachandran | b1425cc | 2014-06-23 18:54:27 -0700 | [diff] [blame] | 39 | |
| 40 | void add(const UidRanges& other); |
| 41 | void remove(const UidRanges& other); |
| 42 | |
Luke Huang | ece6f6b | 2019-04-24 22:18:17 -0700 | [diff] [blame] | 43 | private: |
| 44 | std::vector<UidRangeParcel> mRanges; |
Sreeram Ramachandran | b1425cc | 2014-06-23 18:54:27 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Lorenzo Colitti | 7035f22 | 2017-02-13 18:29:00 +0900 | [diff] [blame] | 47 | } // namespace net |
| 48 | } // namespace android |
| 49 | |
Sreeram Ramachandran | b1425cc | 2014-06-23 18:54:27 -0700 | [diff] [blame] | 50 | #endif // NETD_SERVER_UID_RANGES_H |