1060ff233Sopenharmony_ci/*
2060ff233Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License.
5060ff233Sopenharmony_ci * You may obtain a copy of the License at
6060ff233Sopenharmony_ci *
7060ff233Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8060ff233Sopenharmony_ci *
9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and
13060ff233Sopenharmony_ci * limitations under the License.
14060ff233Sopenharmony_ci */
15060ff233Sopenharmony_ci
16060ff233Sopenharmony_ci/**
17060ff233Sopenharmony_ci * @addtogroup SoftBus
18060ff233Sopenharmony_ci * @{
19060ff233Sopenharmony_ci *
20060ff233Sopenharmony_ci * @brief Provides secure, high-speed communications between devices.
21060ff233Sopenharmony_ci *
22060ff233Sopenharmony_ci * This module implements unified distributed communication management of nearby devices and provides link-independent
23060ff233Sopenharmony_ci * device discovery and transmission interfaces to support service publishing and data transmission.
24060ff233Sopenharmony_ci * @since 1.0
25060ff233Sopenharmony_ci * @version 1.0
26060ff233Sopenharmony_ci */
27060ff233Sopenharmony_ci
28060ff233Sopenharmony_ci/**
29060ff233Sopenharmony_ci * @file dfs_session.h
30060ff233Sopenharmony_ci *
31060ff233Sopenharmony_ci * @brief Declare functions and constants for the distributed file service of DSoftBus. The functions can be used to:
32060ff233Sopenharmony_ci * <ul>
33060ff233Sopenharmony_ci * <li>Obtain the session key and session handle.</li>
34060ff233Sopenharmony_ci * <li>Disable listening for the distributed file service. </li>
35060ff233Sopenharmony_ci *
36060ff233Sopenharmony_ci * @since 1.0
37060ff233Sopenharmony_ci * @version 1.0
38060ff233Sopenharmony_ci */
39060ff233Sopenharmony_ci
40060ff233Sopenharmony_ci#ifndef DFS_SESSION_H
41060ff233Sopenharmony_ci#define DFS_SESSION_H
42060ff233Sopenharmony_ci
43060ff233Sopenharmony_ci#include <stdint.h>
44060ff233Sopenharmony_ci
45060ff233Sopenharmony_ci#ifdef __cplusplus
46060ff233Sopenharmony_ciextern "C" {
47060ff233Sopenharmony_ci#endif
48060ff233Sopenharmony_ci
49060ff233Sopenharmony_ci/**
50060ff233Sopenharmony_ci * @brief Defines the length of the session key, including the terminating null character <b>\0</b>.
51060ff233Sopenharmony_ci *
52060ff233Sopenharmony_ci * @since 1.0
53060ff233Sopenharmony_ci * @version 1.0
54060ff233Sopenharmony_ci */
55060ff233Sopenharmony_ci#define SESSION_KEY_LEN 32
56060ff233Sopenharmony_ci
57060ff233Sopenharmony_ci/**
58060ff233Sopenharmony_ci * @example dfs_demo.c
59060ff233Sopenharmony_ci */
60060ff233Sopenharmony_ci
61060ff233Sopenharmony_ci/**
62060ff233Sopenharmony_ci * @brief Obtains the session key based on the session ID.
63060ff233Sopenharmony_ci *
64060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID.
65060ff233Sopenharmony_ci * @param key Indicates the pointer to the buffer that stores the session key.
66060ff233Sopenharmony_ci * @param len Indicates the length of the buffer.
67060ff233Sopenharmony_ci *
68060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
69060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
70060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
71060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
72060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
73060ff233Sopenharmony_ci * @since 1.0
74060ff233Sopenharmony_ci * @version 1.0
75060ff233Sopenharmony_ci */
76060ff233Sopenharmony_ciint32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len);
77060ff233Sopenharmony_ci
78060ff233Sopenharmony_ci/**
79060ff233Sopenharmony_ci * @brief Obtains the session handle based on the session ID.
80060ff233Sopenharmony_ci *
81060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID.
82060ff233Sopenharmony_ci * @param handle Indicates the pointer to the buffer that stores the session handle.
83060ff233Sopenharmony_ci *
84060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
85060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
86060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
87060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
88060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
89060ff233Sopenharmony_ci * @since 1.0
90060ff233Sopenharmony_ci * @version 1.0
91060ff233Sopenharmony_ci */
92060ff233Sopenharmony_ciint32_t GetSessionHandle(int32_t sessionId, int *handle);
93060ff233Sopenharmony_ci
94060ff233Sopenharmony_ci/**
95060ff233Sopenharmony_ci * @brief Disables the session listener based on the session ID.
96060ff233Sopenharmony_ci *
97060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID.
98060ff233Sopenharmony_ci *
99060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
100060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
101060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
102060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
103060ff233Sopenharmony_ci * @since 1.0
104060ff233Sopenharmony_ci * @version 1.0
105060ff233Sopenharmony_ci */
106060ff233Sopenharmony_ciint32_t DisableSessionListener(int32_t sessionId);
107060ff233Sopenharmony_ci
108060ff233Sopenharmony_ci#ifdef __cplusplus
109060ff233Sopenharmony_ci}
110060ff233Sopenharmony_ci#endif
111060ff233Sopenharmony_ci#endif // DFS_SESSION_H