blob: 43881bed46328f1a00d8e0a990679a0b116a1989 [file] [log] [blame]
Chad Brubakerd2617932013-06-21 15:26:35 -07001/*
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
25class UidMarkMap {
26public:
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);
Chad Brubaker2251c0f2013-06-27 17:20:39 -070030 bool anyRulesForMark(int mark);
Chad Brubakerd2617932013-06-21 15:26:35 -070031
32private:
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