1 /*
2  * Copyright (c) 2020-2022 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 POLICY_DEFINE_H
17 #define POLICY_DEFINE_H
18 
19 #define UID_SIZE 8
20 #define POLICY_SIZE 8
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 typedef struct RegParams {
29     char *service;
30     char *feature;
31     unsigned int uid;
32     unsigned int pid;
33 } RegParams;
34 
35 typedef struct AuthParams {
36     char *providerService;
37     char *providerfeature;
38     unsigned int providerUid;
39     unsigned int providerPid;
40     unsigned int consumerUid;
41     unsigned int consumerPid;
42 } AuthParams;
43 
44 enum PolicyType {
45     RANGE = 1,
46     FIXED = 2,
47     BUNDLENAME = 3
48 };
49 
50 typedef struct PolicyTrans {
51     enum PolicyType type;
52     int fixedUid[UID_SIZE];
53     int uidMin;
54     int uidMax;
55 } PolicyTrans;
56 
57 typedef struct IpcPolicy {
58     enum PolicyType type;
59     int fixedUid[UID_SIZE];
60     int uidMin;
61     int uidMax;
62     char *bundleName;
63 } IpcPolicy;
64 
65 typedef struct FeaturePolicy {
66     char *feature;
67     IpcPolicy policies[POLICY_SIZE];
68 } FeaturePolicy;
69 
70 typedef struct PolicySetting {
71     char *service;
72     FeaturePolicy *features;
73     int featureNum;
74 } PolicySetting;
75 
76 #ifdef __cplusplus
77 #if __cplusplus
78 }
79 #endif
80 #endif
81 #endif // POLICY_DEFINE_H
82