1 /*
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ACCESS_CONTROL_H
17 #define ACCESS_CONTROL_H
18 
19 #ifdef __cplusplus
20 #if __cplusplus
21 extern "C" {
22 #endif
23 #endif
24 
25 // if the upstream module does not set the first caller tokenID, the value is 0
26 #define TOKENID_NOT_SET 0
27 
28 enum FirstTokenType {
29     FOREGROUND_APP_TYPE = 1,
30     BACKGROUND_APP_TYPE = 2,
31     TOKEN_HAP_TYPE = 3,
32     SYSTEM_SA_TYPE = 4,
33     TOKEN_SHELL_TYPE = 5,
34 };
35 
36 int32_t TransCheckClientAccessControl(const char *peerNetworkId);
37 int32_t CheckSecLevelPublic(const char *mySessionName, const char *peerSessionName);
38 int32_t TransCheckServerAccessControl(uint32_t callingTokenId);
39 uint32_t TransACLGetFirstTokenID(void);
40 uint32_t TransACLGetCallingTokenID(void);
41 void TransGetTokenInfo(uint32_t callingId, char *tokenName, int32_t nameLen, int32_t *tokenType);
42 
43 #ifdef __cplusplus
44 #if __cplusplus
45 }
46 #endif /* __cplusplus */
47 #endif /* __cplusplus */
48 
49 #endif /* ACCESS_CONTROL_H */
50