1 /*
2  * Copyright (c) 2020 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 #ifndef LITE_IPC_MANAGER_H
16 #define LITE_IPC_MANAGER_H
17 
18 #include <ipc_auth_interface.h>
19 #include "service.h"
20 #include "iproxy_server.h"
21 #include "endpoint.h"
22 #include "sa_store.h"
23 #include "utils_list.h"
24 
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif
29 #endif
30 #define SAMGR_SERVICE "samgr"
31 #define MAX_SYSCAP_NAME_LEN 64
32 typedef struct SamgrServer SamgrServer;
33 typedef struct SamgrProxy SamgrProxy;
34 typedef struct SysCapImpl SysCapImpl;
35 typedef enum MsgId {
36     MSG_CLEAN,
37 } MsgId;
38 struct SamgrProxy {
39     INHERIT_SERVER_IPROXY;
40 };
41 
42 struct SamgrServer {
43     INHERIT_SERVICE;
44     INHERIT_IPROXY_ENTRY(SamgrProxy);
45     Identity identity;
46     Endpoint *samgr;
47     MutexId mtx;
48     SAStore store;
49     IpcAuthInterface *ipcAuth;
50     MutexId sysCapMtx;
51     Vector sysCapabilitys;
52 };
53 
54 struct SysCapImpl {
55     char name[MAX_SYSCAP_NAME_LEN + 1];
56     BOOL isRegister;
57 };
58 
59 typedef struct {
60     UTILS_DL_LIST list;
61     SaName saName;
62     uintptr_t saId;
63     int token;
64 } SaNode;
65 SaNode *GetSaNodeBySaName(const char *service, const char *feature);
66 SaNode *GetSaNodeBySaId(uintptr_t saId);
67 
68 #ifdef __cplusplus
69 #if __cplusplus
70 }
71 #endif
72 #endif
73 #endif // LITE_IPC_MANAGER_H
74