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