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"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- OAT(OSS Audit Tool) configuration guide:
basedir: Root dir, the basedir + project path is the real source file location.
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.
tasklist(only for batch mode):
1. task: Define oat check thread, each task will start a new thread.
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.
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.
policyList:
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:
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
3. policyitem type:
"compatibility" is used to check license compatibility 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;
"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
"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.
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.
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.
Note:If the text contains special characters, please escape them according to the following rules:
" == &gt;
& == &gt;
' == &gt;
< == &gt;
> == &gt;
-->
<configuration>
<oatconfig>
<licensefile></licensefile>
<filefilterlist>
<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="adapter/.*" desc="Not contains 3rd code, license file is not required in this subdirectory."/>
</filefilter>
<filefilter name="copyrightPolicyFilter" desc="copyright文件头校验策略的过滤条件" >
<filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加版权头"/>
</filefilter>
<filefilter name="defaultPolicyFilter" desc="根目录LICENSE文件校验策略的过滤条件xxx" >
<filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加License"/>
</filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filename" name="*.png" desc="Describes the architecture of the softbus"/>
<filteritem type="filepath" name="figures/.*" desc="Describes the architecture of the softbus"/>
</filefilter>
</filefilterlist>
</oatconfig>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- OAT(OSS Audit Tool) configuration guide:
basedir: Root dir, the basedir + project path is the real source file location.
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.
tasklist(only for batch mode):
1. task: Define oat check thread, each task will start a new thread.
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.
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.
policyList:
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:
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
3. policyitem type:
"compatibility" is used to check license compatibility 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;
"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
"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.
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.
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.
Note:If the text contains special characters, please escape them according to the following rules:
" == &gt;
& == &gt;
' == &gt;
< == &gt;
> == &gt;
-->
<configuration>
<oatconfig>
<licensefile></licensefile>
<filefilterlist>
<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="adapter/.*" desc="Not contains 3rd code, license file is not required in this subdirectory."/>
</filefilter>
<filefilter name="copyrightPolicyFilter" desc="copyright文件头校验策略的过滤条件" >
<filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加版权头"/>
</filefilter>
<filefilter name="defaultPolicyFilter" desc="根目录LICENSE文件校验策略的过滤条件xxx" >
<filteritem type="filepath" name="core/frame/standard/server/src/softbus_server.cfg" desc="cfg文件为json格式,无法添加License"/>
</filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filename" name="*.png" desc="Describes the architecture of the softbus"/>
<filteritem type="filepath" name="figures/.*" desc="Describes the architecture of the softbus"/>
</filefilter>
</filefilterlist>
</oatconfig>
</configuration>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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