fix:repair the windows format

Signed-off-by: mahaoyun1 <mahaoyun1@huawei.com>
This commit is contained in:
mahaoyun1 2022-11-24 15:46:27 +08:00
parent 159e7c4efe
commit 74ef8f1a91
15 changed files with 1306 additions and 1306 deletions

148
OAT.xml
View File

@ -1,74 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd. <!-- Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!-- OAT(OSS Audit Tool) configuration guide: <!-- OAT(OSS Audit Tool) configuration guide:
basedir: Root dir, the basedir + project path is the real source file location. basedir: Root dir, the basedir + project path is the real source file location.
licensefile: licensefile:
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule. 1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
tasklist(only for batch mode): tasklist(only for batch mode):
1. task: Define oat check thread, each task will start a new thread. 1. task: Define oat check thread, each task will start a new thread.
2. task name: Only an name, no practical effect. 2. task name: Only an name, no practical effect.
3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist. 3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist. 4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
5. task project: Projects to be checked, the path field define the source root dir of the project. 5. task project: Projects to be checked, the path field define the source root dir of the project.
policyList: policyList:
1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process. 1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is: 2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/> <policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
3. policyitem type: 3. policyitem type:
"compatibility" is used to check license compatibility in the specified path; "compatibility" is used to check license compatibility in the specified path;
"license" is used to check source license header in the specified path; "license" is used to check source license header in the specified path;
"copyright" is used to check source copyright header in the specified path; "copyright" is used to check source copyright header in the specified path;
"import" is used to check source dependency in the specified path, such as import ... ,include ... "import" is used to check source dependency in the specified path, such as import ... ,include ...
"filetype" is used to check file type in the specified path, supported file types: archive, binary "filetype" is used to check file type in the specified path, supported file types: archive, binary
"filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource "filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license. 4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem. 5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed. 6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
7. policyitem filefilter: Used to bind filefilter which define filter rules. 7. policyitem filefilter: Used to bind filefilter which define filter rules.
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path. 8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
Note:If the text contains special characters, please escape them according to the following rules: Note:If the text contains special characters, please escape them according to the following rules:
" == &gt; " == &gt;
& == &gt; & == &gt;
' == &gt; ' == &gt;
< == &gt; < == &gt;
> == &gt; > == &gt;
--> -->
<configuration> <configuration>
<oatconfig> <oatconfig>
<licensefile></licensefile> <licensefile></licensefile>
<filefilterlist> <filefilterlist>
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies" > <filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies" >
<filteritem type="filepath" name="core/adapter/.*" desc="Not contains 3rd code, license file is not required in this subdirectory."/> <filteritem type="filepath" name="core/adapter/.*" desc="Not contains 3rd code, license file is not required in this subdirectory."/>
<filteritem type="filepath" name="adapter/.*" desc="Not contains 3rd code, license file is not required in this subdirectory."/> <filteritem type="filepath" name="adapter/.*" desc="Not contains 3rd code, license file is not required in this subdirectory."/>
</filefilter> </filefilter>
<filefilter name="copyrightPolicyFilter" desc="copyright文件头校验策略的过滤条件" > <filefilter name="copyrightPolicyFilter" desc="copyright文件头校验策略的过滤条件" >
<filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加版权头"/> <filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加版权头"/>
</filefilter> </filefilter>
<filefilter name="defaultPolicyFilter" desc="根目录LICENSE文件校验策略的过滤条件xxx" > <filefilter name="defaultPolicyFilter" desc="根目录LICENSE文件校验策略的过滤条件xxx" >
<filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加License"/> <filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加License"/>
</filefilter> </filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies"> <filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filename" name="*.png" desc="Describes the architecture of the softbus"/> <filteritem type="filename" name="*.png" desc="Describes the architecture of the softbus"/>
<filteritem type="filepath" name="figures/.*" desc="Describes the architecture of the softbus"/> <filteritem type="filepath" name="figures/.*" desc="Describes the architecture of the softbus"/>
</filefilter> </filefilter>
</filefilterlist> </filefilterlist>
</oatconfig> </oatconfig>
</configuration> </configuration>

View File

@ -1,48 +1,48 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "lnn_time_sync_impl.h" #include "lnn_time_sync_impl.h"
#include "softbus_errcode.h" #include "softbus_errcode.h"
#include "softbus_log.h" #include "softbus_log.h"
int32_t LnnTimeSyncImplInit(void) int32_t LnnTimeSyncImplInit(void)
{ {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "time sync impl stub init success"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "time sync impl stub init success");
return SOFTBUS_OK; return SOFTBUS_OK;
} }
void LnnTimeSyncImplDeinit(void) void LnnTimeSyncImplDeinit(void)
{ {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "time sync impl stub deinit"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "time sync impl stub deinit");
} }
int32_t LnnStartTimeSyncImpl(const char *targetNetworkId, TimeSyncAccuracy accuracy, int32_t LnnStartTimeSyncImpl(const char *targetNetworkId, TimeSyncAccuracy accuracy,
TimeSyncPeriod period, const TimeSyncImplCallback *callback) TimeSyncPeriod period, const TimeSyncImplCallback *callback)
{ {
(void)targetNetworkId; (void)targetNetworkId;
(void)accuracy; (void)accuracy;
(void)period; (void)period;
(void)callback; (void)callback;
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "start time sync stub impl"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "start time sync stub impl");
return SOFTBUS_NOT_IMPLEMENT; return SOFTBUS_NOT_IMPLEMENT;
} }
int32_t LnnStopTimeSyncImpl(const char *targetNetworkId) int32_t LnnStopTimeSyncImpl(const char *targetNetworkId)
{ {
(void)targetNetworkId; (void)targetNetworkId;
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "stop time sync stub impl"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "stop time sync stub impl");
return SOFTBUS_NOT_IMPLEMENT; return SOFTBUS_NOT_IMPLEMENT;
} }

View File

@ -1,46 +1,46 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "lnn_time_sync_manager.h" #include "lnn_time_sync_manager.h"
#include "softbus_errcode.h" #include "softbus_errcode.h"
#include "softbus_log.h" #include "softbus_log.h"
int32_t LnnStartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t LnnStartTimeSync(const char *pkgName, const char *targetNetworkId,
TimeSyncAccuracy accuracy, TimeSyncPeriod period) TimeSyncAccuracy accuracy, TimeSyncPeriod period)
{ {
(void)pkgName; (void)pkgName;
(void)targetNetworkId; (void)targetNetworkId;
(void)accuracy; (void)accuracy;
(void)period; (void)period;
return SOFTBUS_NOT_IMPLEMENT; return SOFTBUS_NOT_IMPLEMENT;
} }
int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId) int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId)
{ {
(void)pkgName; (void)pkgName;
(void)targetNetworkId; (void)targetNetworkId;
return SOFTBUS_NOT_IMPLEMENT; return SOFTBUS_NOT_IMPLEMENT;
} }
int32_t LnnInitTimeSync(void) int32_t LnnInitTimeSync(void)
{ {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "time sync virtual init success"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "time sync virtual init success");
return SOFTBUS_OK; return SOFTBUS_OK;
} }
void LnnDeinitTimeSync(void) void LnnDeinitTimeSync(void)
{ {
} }

View File

@ -1,31 +1,31 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef LNN_EVENT_MONITOR_H #ifndef LNN_EVENT_MONITOR_H
#define LNN_EVENT_MONITOR_H #define LNN_EVENT_MONITOR_H
#include <stdint.h> #include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int32_t LnnInitEventMonitor(void); int32_t LnnInitEventMonitor(void);
void LnnDeinitEventMonitor(); void LnnDeinitEventMonitor();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* LNN_EVENT_MONITOR_H */ #endif /* LNN_EVENT_MONITOR_H */

View File

@ -1,80 +1,80 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "lnn_event_monitor.h" #include "lnn_event_monitor.h"
#include <pthread.h> #include <pthread.h>
#include <securec.h> #include <securec.h>
#include "bus_center_event.h" #include "bus_center_event.h"
#include "lnn_event_monitor_impl.h" #include "lnn_event_monitor_impl.h"
#include "lnn_devicename_info.h" #include "lnn_devicename_info.h"
#include "lnn_settingdata_event_monitor.h" #include "lnn_settingdata_event_monitor.h"
#include "softbus_errcode.h" #include "softbus_errcode.h"
#include "softbus_log.h" #include "softbus_log.h"
#include "softbus_adapter_mem.h" #include "softbus_adapter_mem.h"
typedef enum { typedef enum {
MONITOR_IMPL_NETLINK_TYPE = 0, MONITOR_IMPL_NETLINK_TYPE = 0,
MONITOR_IMPL_PRODUCT_TYPE, MONITOR_IMPL_PRODUCT_TYPE,
MONITOR_IMPL_LWIP_TYPE, MONITOR_IMPL_LWIP_TYPE,
MONITOR_IMPL_WIFISERVICE_TYPE, MONITOR_IMPL_WIFISERVICE_TYPE,
MONITOR_IMPL_BT_STATE_TYPE, MONITOR_IMPL_BT_STATE_TYPE,
MONITOR_IMPL_DRIVER_TYPE, MONITOR_IMPL_DRIVER_TYPE,
MONITOR_IMPL_SCREENSTATE_TYPE, MONITOR_IMPL_SCREENSTATE_TYPE,
MONITOR_IMPL_DEVICENAME_TYPE, MONITOR_IMPL_DEVICENAME_TYPE,
MONITOR_IMPL_MAX_TYPE, MONITOR_IMPL_MAX_TYPE,
} MonitorImplType; } MonitorImplType;
static LnnInitEventMonitorImpl g_monitorImplInit[MONITOR_IMPL_MAX_TYPE] = { static LnnInitEventMonitorImpl g_monitorImplInit[MONITOR_IMPL_MAX_TYPE] = {
LnnInitNetlinkMonitorImpl, LnnInitNetlinkMonitorImpl,
LnnInitProductMonitorImpl, LnnInitProductMonitorImpl,
LnnInitLwipMonitorImpl, LnnInitLwipMonitorImpl,
LnnInitWifiServiceMonitorImpl, LnnInitWifiServiceMonitorImpl,
LnnInitBtStateMonitorImpl, LnnInitBtStateMonitorImpl,
LnnInitDriverMonitorImpl, LnnInitDriverMonitorImpl,
LnnInitCommonEventMonitorImpl, LnnInitCommonEventMonitorImpl,
LnnInitDeviceNameMonitorImpl, LnnInitDeviceNameMonitorImpl,
}; };
static LnnDeinitEventMonitorImpl g_monitorImplDeinit[MONITOR_IMPL_MAX_TYPE] = { static LnnDeinitEventMonitorImpl g_monitorImplDeinit[MONITOR_IMPL_MAX_TYPE] = {
LnnDeinitBtStateMonitorImpl, LnnDeinitBtStateMonitorImpl,
}; };
int32_t LnnInitEventMonitor(void) int32_t LnnInitEventMonitor(void)
{ {
for (uint32_t i = 0; i < MONITOR_IMPL_MAX_TYPE; ++i) { for (uint32_t i = 0; i < MONITOR_IMPL_MAX_TYPE; ++i) {
if (g_monitorImplInit[i] == NULL) { if (g_monitorImplInit[i] == NULL) {
continue; continue;
} }
if (g_monitorImplInit[i]() != SOFTBUS_OK) { if (g_monitorImplInit[i]() != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init event monitor impl(%u) failed", i); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init event monitor impl(%u) failed", i);
return SOFTBUS_ERR; return SOFTBUS_ERR;
} }
} }
return SOFTBUS_OK; return SOFTBUS_OK;
} }
void LnnDeinitEventMonitor(void) void LnnDeinitEventMonitor(void)
{ {
uint32_t i; uint32_t i;
for (i = 0; i < MONITOR_IMPL_MAX_TYPE; ++i) { for (i = 0; i < MONITOR_IMPL_MAX_TYPE; ++i) {
if (g_monitorImplDeinit[i] == NULL) { if (g_monitorImplDeinit[i] == NULL) {
continue; continue;
} }
g_monitorImplDeinit[i](); g_monitorImplDeinit[i]();
} }
} }

View File

@ -1,29 +1,29 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "lnn_event_monitor.h" #include "lnn_event_monitor.h"
#include "softbus_errcode.h" #include "softbus_errcode.h"
#include "softbus_log.h" #include "softbus_log.h"
int32_t LnnInitEventMonitor(void) int32_t LnnInitEventMonitor(void)
{ {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "init virtual event monitor"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "init virtual event monitor");
return SOFTBUS_OK; return SOFTBUS_OK;
} }
void LnnDeinitEventMonitor(void) void LnnDeinitEventMonitor(void)
{ {
} }

View File

@ -1,37 +1,37 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef LNN_ASYNC_CALLBACK_UTILS_H #ifndef LNN_ASYNC_CALLBACK_UTILS_H
#define LNN_ASYNC_CALLBACK_UTILS_H #define LNN_ASYNC_CALLBACK_UTILS_H
#include <stdint.h> #include <stdint.h>
#include "message_handler.h" #include "message_handler.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef void (*LnnAsyncCallbackFunc)(void *para); typedef void (*LnnAsyncCallbackFunc)(void *para);
int32_t LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para); int32_t LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para);
int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
void *para, uint64_t delayMillis); void *para, uint64_t delayMillis);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* LNN_CONNECTION_ADDR_UTILS_H */ #endif /* LNN_CONNECTION_ADDR_UTILS_H */

View File

@ -1,37 +1,37 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef LNN_FILE_UTILS_H #ifndef LNN_FILE_UTILS_H
#define LNN_FILE_UTILS_H #define LNN_FILE_UTILS_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef enum { typedef enum {
LNN_FILE_ID_UUID, LNN_FILE_ID_UUID,
LNN_FILE_ID_DB_KEY, LNN_FILE_ID_DB_KEY,
LNN_FILE_ID_MAX LNN_FILE_ID_MAX
} LnnFileId; } LnnFileId;
int32_t LnnGetFullStoragePath(LnnFileId id, char *path, uint32_t len); int32_t LnnGetFullStoragePath(LnnFileId id, char *path, uint32_t len);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* LNN_FILE_UTILS_H */ #endif /* LNN_FILE_UTILS_H */

View File

@ -1,34 +1,34 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef LNN_IPC_UTILS_H #ifndef LNN_IPC_UTILS_H
#define LNN_IPC_UTILS_H #define LNN_IPC_UTILS_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "softbus_bus_center.h" #include "softbus_bus_center.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void ConvertVoidToPublishInfo(const void *info, PublishInfo *pubInfo); void ConvertVoidToPublishInfo(const void *info, PublishInfo *pubInfo);
void ConvertVoidToSubscribeInfo(const void *info, SubscribeInfo *subInfo); void ConvertVoidToSubscribeInfo(const void *info, SubscribeInfo *subInfo);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* LNN_IPC_UTILS_H */ #endif /* LNN_IPC_UTILS_H */

View File

@ -1,133 +1,133 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "lnn_async_callback_utils.h" #include "lnn_async_callback_utils.h"
#include "common_list.h" #include "common_list.h"
#include "softbus_adapter_mem.h" #include "softbus_adapter_mem.h"
#include "softbus_errcode.h" #include "softbus_errcode.h"
#include "softbus_log.h" #include "softbus_log.h"
#define LNN_ASYNC_CALLBACK_HANDLER_NAME "LnnAsyncHandler" #define LNN_ASYNC_CALLBACK_HANDLER_NAME "LnnAsyncHandler"
#define LNN_ASYNC_CALLBACK_REG 0 #define LNN_ASYNC_CALLBACK_REG 0
typedef struct { typedef struct {
SoftBusMessage msg; SoftBusMessage msg;
SoftBusHandler handler; SoftBusHandler handler;
LnnAsyncCallbackFunc callback; LnnAsyncCallbackFunc callback;
void *cbPara; void *cbPara;
} AsyncCallbackInfo; } AsyncCallbackInfo;
#define TO_ASYNC_CALLBACK_INFO(cb) CONTAINER_OF(cb, AsyncCallbackInfo, callback) #define TO_ASYNC_CALLBACK_INFO(cb) CONTAINER_OF(cb, AsyncCallbackInfo, callback)
static void AsyncCallbackHandler(SoftBusMessage *msg) static void AsyncCallbackHandler(SoftBusMessage *msg)
{ {
AsyncCallbackInfo *info = NULL; AsyncCallbackInfo *info = NULL;
if (msg == NULL) { if (msg == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail async callback recv null msg"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail async callback recv null msg");
return; return;
} }
info = (AsyncCallbackInfo *)msg->obj; info = (AsyncCallbackInfo *)msg->obj;
if (info == NULL) { if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail async callback recv null info"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail async callback recv null info");
return; return;
} }
if (info->callback == NULL) { if (info->callback == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail async callback function is null"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail async callback function is null");
return; return;
} }
info->callback(info->cbPara); info->callback(info->cbPara);
} }
static void FreeAsyncCallbackMessage(SoftBusMessage *msg) static void FreeAsyncCallbackMessage(SoftBusMessage *msg)
{ {
AsyncCallbackInfo *info = NULL; AsyncCallbackInfo *info = NULL;
if (msg == NULL || msg->obj == NULL) { if (msg == NULL || msg->obj == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail: looper or callback is null"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail: looper or callback is null");
return; return;
} }
info = (AsyncCallbackInfo *)msg->obj; info = (AsyncCallbackInfo *)msg->obj;
SoftBusFree(info); SoftBusFree(info);
} }
static void InitAsyncCallbackMessage(SoftBusMessage *msg, int32_t what, void *obj, SoftBusHandler *handler) static void InitAsyncCallbackMessage(SoftBusMessage *msg, int32_t what, void *obj, SoftBusHandler *handler)
{ {
msg->what = what; msg->what = what;
msg->obj = obj; msg->obj = obj;
msg->handler = handler; msg->handler = handler;
msg->FreeMessage = FreeAsyncCallbackMessage; msg->FreeMessage = FreeAsyncCallbackMessage;
} }
static void InitAsyncCallbackHandler(SoftBusHandler *handler, SoftBusLooper *looper) static void InitAsyncCallbackHandler(SoftBusHandler *handler, SoftBusLooper *looper)
{ {
handler->name = LNN_ASYNC_CALLBACK_HANDLER_NAME; handler->name = LNN_ASYNC_CALLBACK_HANDLER_NAME;
handler->looper = looper; handler->looper = looper;
handler->HandleMessage = AsyncCallbackHandler; handler->HandleMessage = AsyncCallbackHandler;
} }
static AsyncCallbackInfo *CreateAsyncCallbackInfo(SoftBusLooper *looper, static AsyncCallbackInfo *CreateAsyncCallbackInfo(SoftBusLooper *looper,
LnnAsyncCallbackFunc callback, void *para, int32_t msgType) LnnAsyncCallbackFunc callback, void *para, int32_t msgType)
{ {
AsyncCallbackInfo *info = NULL; AsyncCallbackInfo *info = NULL;
info = SoftBusCalloc(sizeof(AsyncCallbackInfo)); info = SoftBusCalloc(sizeof(AsyncCallbackInfo));
if (info == NULL) { if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail to malloc async callback info"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail to malloc async callback info");
return NULL; return NULL;
} }
info->callback = callback; info->callback = callback;
info->cbPara = para; info->cbPara = para;
InitAsyncCallbackHandler(&info->handler, looper); InitAsyncCallbackHandler(&info->handler, looper);
InitAsyncCallbackMessage(&info->msg, msgType, (void *)info, &info->handler); InitAsyncCallbackMessage(&info->msg, msgType, (void *)info, &info->handler);
return info; return info;
} }
int32_t LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para) int32_t LnnAsyncCallbackHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para)
{ {
AsyncCallbackInfo *info = NULL; AsyncCallbackInfo *info = NULL;
if (looper == NULL || callback == NULL) { if (looper == NULL || callback == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail: looper or callback is null"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail: looper or callback is null");
return SOFTBUS_INVALID_PARAM; return SOFTBUS_INVALID_PARAM;
} }
info = CreateAsyncCallbackInfo(looper, callback, para, LNN_ASYNC_CALLBACK_REG); info = CreateAsyncCallbackInfo(looper, callback, para, LNN_ASYNC_CALLBACK_REG);
if (info == NULL) { if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail to create async callback info"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail to create async callback info");
return SOFTBUS_MEM_ERR; return SOFTBUS_MEM_ERR;
} }
looper->PostMessage(looper, &info->msg); looper->PostMessage(looper, &info->msg);
return SOFTBUS_OK; return SOFTBUS_OK;
} }
int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
void *para, uint64_t delayMillis) void *para, uint64_t delayMillis)
{ {
AsyncCallbackInfo *info = NULL; AsyncCallbackInfo *info = NULL;
if (looper == NULL || callback == NULL) { if (looper == NULL || callback == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail: looper or callback is null"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail: looper or callback is null");
return SOFTBUS_INVALID_PARAM; return SOFTBUS_INVALID_PARAM;
} }
info = CreateAsyncCallbackInfo(looper, callback, para, LNN_ASYNC_CALLBACK_REG); info = CreateAsyncCallbackInfo(looper, callback, para, LNN_ASYNC_CALLBACK_REG);
if (info == NULL) { if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail to create async callback info"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "fail to create async callback info");
return SOFTBUS_MEM_ERR; return SOFTBUS_MEM_ERR;
} }
looper->PostMessageDelay(looper, &info->msg, delayMillis); looper->PostMessageDelay(looper, &info->msg, delayMillis);
return SOFTBUS_OK; return SOFTBUS_OK;
} }

View File

@ -1,73 +1,73 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "lnn_file_utils.h" #include "lnn_file_utils.h"
#include <securec.h> #include <securec.h>
#include "softbus_adapter_file.h" #include "softbus_adapter_file.h"
#include "softbus_errcode.h" #include "softbus_errcode.h"
#include "softbus_feature_config.h" #include "softbus_feature_config.h"
#include "softbus_log.h" #include "softbus_log.h"
#define DEFAULT_STORAGE_PATH "/data/service/el1/public" #define DEFAULT_STORAGE_PATH "/data/service/el1/public"
typedef struct { typedef struct {
LnnFileId fileId; LnnFileId fileId;
const char *filePath; const char *filePath;
} FilePathInfo; } FilePathInfo;
static char g_storagePath[SOFTBUS_MAX_PATH_LEN] = {0}; static char g_storagePath[SOFTBUS_MAX_PATH_LEN] = {0};
static FilePathInfo g_filePath[LNN_FILE_ID_MAX] = { static FilePathInfo g_filePath[LNN_FILE_ID_MAX] = {
{ LNN_FILE_ID_UUID, "/dsoftbus/uuid" }, { LNN_FILE_ID_UUID, "/dsoftbus/uuid" },
{ LNN_FILE_ID_DB_KEY, "/dsoftbus/dbKey" }, { LNN_FILE_ID_DB_KEY, "/dsoftbus/dbKey" },
}; };
static int32_t InitStorageConfigPath(void) static int32_t InitStorageConfigPath(void)
{ {
if (SoftbusGetConfig(SOFTBUS_STR_STORAGE_DIRECTORY, (uint8_t *)g_storagePath, if (SoftbusGetConfig(SOFTBUS_STR_STORAGE_DIRECTORY, (uint8_t *)g_storagePath,
SOFTBUS_MAX_PATH_LEN) != SOFTBUS_OK) { SOFTBUS_MAX_PATH_LEN) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "read storage path fail"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "read storage path fail");
if (strncpy_s(g_storagePath, SOFTBUS_MAX_PATH_LEN, DEFAULT_STORAGE_PATH, if (strncpy_s(g_storagePath, SOFTBUS_MAX_PATH_LEN, DEFAULT_STORAGE_PATH,
strlen(DEFAULT_STORAGE_PATH)) != EOK) { strlen(DEFAULT_STORAGE_PATH)) != EOK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "copy default storage path fail"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "copy default storage path fail");
g_storagePath[0] = '\0'; g_storagePath[0] = '\0';
return SOFTBUS_ERR; return SOFTBUS_ERR;
} }
} }
return SOFTBUS_OK; return SOFTBUS_OK;
} }
int32_t LnnGetFullStoragePath(LnnFileId id, char *path, uint32_t len) int32_t LnnGetFullStoragePath(LnnFileId id, char *path, uint32_t len)
{ {
if (path == NULL) { if (path == NULL) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "%s: path is null", __func__); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "%s: path is null", __func__);
return SOFTBUS_INVALID_PARAM; return SOFTBUS_INVALID_PARAM;
} }
if (strlen(g_storagePath) == 0) { if (strlen(g_storagePath) == 0) {
if (InitStorageConfigPath() != SOFTBUS_OK) { if (InitStorageConfigPath() != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init storage config path fail"); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init storage config path fail");
return SOFTBUS_ERR; return SOFTBUS_ERR;
} }
} }
if (strncpy_s(path, len, g_storagePath, strlen(g_storagePath)) != EOK || if (strncpy_s(path, len, g_storagePath, strlen(g_storagePath)) != EOK ||
strncat_s(path, len, g_filePath[id].filePath, strlen(g_filePath[id].filePath)) != EOK) { strncat_s(path, len, g_filePath[id].filePath, strlen(g_filePath[id].filePath)) != EOK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "splice full path for %d fail", id); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "splice full path for %d fail", id);
return SOFTBUS_ERR; return SOFTBUS_ERR;
} }
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "full path for %d is %s", id, path); SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "full path for %d is %s", id, path);
return SOFTBUS_OK; return SOFTBUS_OK;
} }

View File

@ -1,70 +1,70 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "lnn_ipc_utils.h" #include "lnn_ipc_utils.h"
#include <string.h> #include <string.h>
void ConvertVoidToPublishInfo(const void *info, PublishInfo *pubInfo) void ConvertVoidToPublishInfo(const void *info, PublishInfo *pubInfo)
{ {
if (info == NULL || pubInfo == NULL) { if (info == NULL || pubInfo == NULL) {
return; return;
} }
char *info1 = (char *)info; char *info1 = (char *)info;
pubInfo->publishId = *(int32_t *)info1; pubInfo->publishId = *(int32_t *)info1;
info1 += sizeof(int32_t); info1 += sizeof(int32_t);
pubInfo->mode = *(DiscoverMode *)info1; pubInfo->mode = *(DiscoverMode *)info1;
info1 += sizeof(DiscoverMode); info1 += sizeof(DiscoverMode);
pubInfo->medium = *(ExchangeMedium *)info1; pubInfo->medium = *(ExchangeMedium *)info1;
info1 += sizeof(ExchangeMedium); info1 += sizeof(ExchangeMedium);
pubInfo->freq = *(ExchangeFreq *)info1; pubInfo->freq = *(ExchangeFreq *)info1;
info1 += sizeof(ExchangeFreq); info1 += sizeof(ExchangeFreq);
pubInfo->capability = (const char *)info1; pubInfo->capability = (const char *)info1;
info1 += strlen(pubInfo->capability) + 1; info1 += strlen(pubInfo->capability) + 1;
pubInfo->dataLen = *(int32_t *)info1; pubInfo->dataLen = *(int32_t *)info1;
info1 += sizeof(int32_t); info1 += sizeof(int32_t);
if (pubInfo->dataLen > 0) { if (pubInfo->dataLen > 0) {
pubInfo->capabilityData = (unsigned char *)info1; pubInfo->capabilityData = (unsigned char *)info1;
info1 += pubInfo->dataLen + 1; info1 += pubInfo->dataLen + 1;
} }
pubInfo->ranging = *(bool *)info1; pubInfo->ranging = *(bool *)info1;
} }
void ConvertVoidToSubscribeInfo(const void *info, SubscribeInfo *subInfo) void ConvertVoidToSubscribeInfo(const void *info, SubscribeInfo *subInfo)
{ {
if (info == NULL || subInfo == NULL) { if (info == NULL || subInfo == NULL) {
return; return;
} }
char *info1 = (char *)info; char *info1 = (char *)info;
subInfo->subscribeId = *(int32_t *)info1; subInfo->subscribeId = *(int32_t *)info1;
info1 += sizeof(int32_t); info1 += sizeof(int32_t);
subInfo->mode = *(DiscoverMode *)info1; subInfo->mode = *(DiscoverMode *)info1;
info1 += sizeof(DiscoverMode); info1 += sizeof(DiscoverMode);
subInfo->medium = *(ExchangeMedium *)info1; subInfo->medium = *(ExchangeMedium *)info1;
info1 += sizeof(ExchangeMedium); info1 += sizeof(ExchangeMedium);
subInfo->freq = *(ExchangeFreq *)info1; subInfo->freq = *(ExchangeFreq *)info1;
info1 += sizeof(ExchangeFreq); info1 += sizeof(ExchangeFreq);
subInfo->isSameAccount = *(bool *)info1; subInfo->isSameAccount = *(bool *)info1;
info1 += sizeof(bool); info1 += sizeof(bool);
subInfo->isWakeRemote = *(bool *)info1; subInfo->isWakeRemote = *(bool *)info1;
info1 += sizeof(bool); info1 += sizeof(bool);
subInfo->capability = (const char *)info1; subInfo->capability = (const char *)info1;
info1 += strlen(subInfo->capability) + 1; info1 += strlen(subInfo->capability) + 1;
subInfo->dataLen = *(int32_t *)info1; subInfo->dataLen = *(int32_t *)info1;
info1 += sizeof(int32_t); info1 += sizeof(int32_t);
if (subInfo->dataLen > 0) { if (subInfo->dataLen > 0) {
subInfo->capabilityData = (unsigned char *)info1; subInfo->capabilityData = (unsigned char *)info1;
} }
} }

View File

@ -1,34 +1,34 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef DFS_SESSION_H #ifndef DFS_SESSION_H
#define DFS_SESSION_H #define DFS_SESSION_H
#include <stdint.h> #include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define SESSION_KEY_LEN 32 #define SESSION_KEY_LEN 32
int32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len); int32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len);
int32_t GetSessionHandle(int32_t sessionId, int *handle); int32_t GetSessionHandle(int32_t sessionId, int *handle);
int32_t DisableSessionListener(int32_t sessionId); int32_t DisableSessionListener(int32_t sessionId);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // DFS_SESSION_H #endif // DFS_SESSION_H

View File

@ -1,31 +1,31 @@
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef INNER_SESSION_H #ifndef INNER_SESSION_H
#define INNER_SESSION_H #define INNER_SESSION_H
#include "softbus_common.h" #include "softbus_common.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo, int num, const char *mixAddr); int OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo, int num, const char *mixAddr);
void NotifyAuthSuccess(int sessionId); void NotifyAuthSuccess(int sessionId);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif