1 /*
2  * Copyright (C) 2017 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 __CUTILS_QTAGUID_H
18 #define __CUTILS_QTAGUID_H
19 
20 #include <sys/types.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /*
27  * Set tags (and owning UIDs) for network sockets.
28  */
29 extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid);
30 
31 /*
32  * Untag a network socket before closing.
33  */
34 extern int qtaguid_untagSocket(int sockfd);
35 
36 /*
37  * For the given uid, switch counter sets.
38  * The kernel only keeps a limited number of sets.
39  * 2 for now.
40  */
41 extern int qtaguid_setCounterSet(int counterSetNum, uid_t uid);
42 
43 /*
44  * Delete all tag info that relates to the given tag an uid.
45  * If the tag is 0, then ALL info about the uid is freed.
46  * The delete data also affects active tagged sockets, which are
47  * then untagged.
48  * The calling process can only operate on its own tags.
49  * Unless it is part of the happy AID_NET_BW_ACCT group.
50  * In which case it can clobber everything.
51  */
52 extern int qtaguid_deleteTagData(int tag, uid_t uid);
53 
54 /*
55  * Enable/disable qtaguid functionnality at a lower level.
56  * When pacified, the kernel will accept commands but do nothing.
57  */
58 extern int qtaguid_setPacifier(int on);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif /* __CUTILS_QTAG_UID_H */
65