1 /*
2  * Copyright (C) 2021 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 OHOS_WIFI_HAL_MODULE_MANAGE_H
17 #define OHOS_WIFI_HAL_MODULE_MANAGE_H
18 
19 #include <pthread.h>
20 #include <stdbool.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define MAX_MODULE_NAME_SIZE 32
27 #define MAX_LINE_SIZE 1024
28 
29 typedef enum ModuleStatus {
30     UNKNOWN = -1, /* when check module status failed */
31     ACTIVE = 0,
32     INACTIVE = 1,
33 } ModuleStatus;
34 
35 typedef struct StModuleInfo {
36     char szModuleName[MAX_MODULE_NAME_SIZE];
37     int referenceCount;
38     pid_t processId;
39     struct StModuleInfo *next;
40 } ModuleInfo;
41 
42 typedef enum ModuleManageRetCode {
43     MM_FAILED = -1,
44     MM_SUCCESS = 0,
45     MM_REDUCE_REFERENCE = 1,
46 } ModuleManageRetCode;
47 
48 /**
49  * @Description Starts a specified service.
50  *
51  * @param moduleName
52  * @param modulePropertyName
53  * @param startCmd
54  * @return ModuleManageRetCode
55  */
56 ModuleManageRetCode StartModule(const char *moduleName, const char *startCmd);
57 
58 /**
59  * @Description Stop a specified service.
60  *
61  * @param moduleName
62  * @param isHostapd
63  * @return ModuleManageRetCode
64  */
65 ModuleManageRetCode StopModule(const char *moduleName, bool isHostapd);
66 
67 /**
68  * @Description Get started service.
69  *
70  * @return ModuleManageRetCode
71  */
72 
73 ModuleInfo *GetStartedModule(void);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 #endif