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 
18 #ifndef _VTS_SYSTEM_QTAGUID_SOCKET_TAG_USER_SPACE_
19 #define _VTS_SYSTEM_QTAGUID_SOCKET_TAG_USER_SPACE_
20 
21 #include <stdint.h>
22 #include <stdlib.h>
23 
24 namespace android {
25 
26 // Class created to store socket file description and setup socket
27 class SockInfo {
28  public:
SockInfo()29   SockInfo() : fd(-1) {}
30   // set up the socket and verify it by trying to tag it
31   int setup(int tag);
32   // helper function check if the socket is tagged correctly
33   bool checkTag(uint64_t acct_tag, uid_t uid);
34   // helper function check if the socket traffic is properly recorded.
35   bool checkStats(uint64_t acct_tag, uid_t uid, int counterSet,
36                   uint32_t *stats_result);
37   // socket file description
38   int fd;
39 };
40 
41 }  // namespace android
42 
43 #endif  // _VTS_SYSTEM_QTAGUID_SOCKET_TAG_USER_SPACE_
44