OSDN Git Service

Merge "Host exemption now handles premarked sockets"
[android-x86/system-netd.git] / UidMarkMap.h
1 /*
2  * Copyright (C) 2013 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_UIDMARKMAP_H
18 #define _NETD_UIDMARKMAP_H
19
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <List.h>
23 #include <utils/RWLock.h>
24
25 class UidMarkMap {
26 public:
27     bool add(int uid_start, int uid_end, int mark);
28     bool remove(int uid_start, int uid_end, int mark);
29     int getMark(int uid);
30     bool anyRulesForMark(int mark);
31
32 private:
33     struct UidMarkEntry {
34         int uid_start;
35         int uid_end;
36         int mark;
37         UidMarkEntry(int uid_start, int uid_end, int mark);
38     };
39
40     android::RWLock mRWLock;
41     android::netd::List<UidMarkEntry*> mMap;
42 };
43 #endif