1 /*
2  * Copyright (c) 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 CERT_MANAGER_SESSION_MGR_H
17 #define CERT_MANAGER_SESSION_MGR_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "cert_manager_double_list.h"
23 #include "cm_type.h"
24 
25 struct CmSessionNodeInfo {
26     uint32_t userId;
27     uint32_t uid;
28     struct CmBlob uri; /* origin uri */
29 };
30 
31 struct CmSessionNode {
32     struct DoubleList listHead;
33     struct CmSessionNodeInfo info;
34     struct CmBlob handle;
35     bool abortable;
36 };
37 
38 enum CmSessionDeleteType {
39     DELETE_SESSION_BY_USERID,
40     DELETE_SESSION_BY_UID,
41     DELETE_SESSION_BY_URI,
42     DELETE_SESSION_BY_ALL,
43 };
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 int32_t CmCreateSession(const struct CmSessionNodeInfo *info, const struct CmBlob *handle, bool abortable);
50 
51 struct CmSessionNode *CmQuerySession(const struct CmSessionNodeInfo *info, const struct CmBlob *handle);
52 
53 void CmDeleteSession(const struct CmBlob *handle);
54 
55 void CmDeleteSessionByNodeInfo(enum CmSessionDeleteType deleteType, const struct CmSessionNodeInfo *info);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif /* CERT_MANAGER_SESSION_MGR_H */
62