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