1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup SoftBus
18  * @{
19  *
20  * @brief Provides secure, high-speed communications between devices.
21  *
22  * This module implements unified distributed communication management of nearby devices and provides link-independent
23  * device discovery and transmission interfaces to support service publishing and data transmission.
24  * @since 1.0
25  * @version 1.0
26  */
27 
28 /**
29  * @file dfs_session.h
30  *
31  * @brief Declare functions and constants for the distributed file service of DSoftBus. The functions can be used to:
32  * <ul>
33  * <li>Obtain the session key and session handle.</li>
34  * <li>Disable listening for the distributed file service. </li>
35  *
36  * @since 1.0
37  * @version 1.0
38  */
39 
40 #ifndef DFS_SESSION_H
41 #define DFS_SESSION_H
42 
43 #include <stdint.h>
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /**
50  * @brief Defines the length of the session key, including the terminating null character <b>\0</b>.
51  *
52  * @since 1.0
53  * @version 1.0
54  */
55 #define SESSION_KEY_LEN 32
56 
57 /**
58  * @example dfs_demo.c
59  */
60 
61 /**
62  * @brief Obtains the session key based on the session ID.
63  *
64  * @param sessionId Indicates the unique session ID.
65  * @param key Indicates the pointer to the buffer that stores the session key.
66  * @param len Indicates the length of the buffer.
67  *
68  * @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
69  * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
70  * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
71  * @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
72  * @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
73  * @since 1.0
74  * @version 1.0
75  */
76 int32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len);
77 
78 /**
79  * @brief Obtains the session handle based on the session ID.
80  *
81  * @param sessionId Indicates the unique session ID.
82  * @param handle Indicates the pointer to the buffer that stores the session handle.
83  *
84  * @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
85  * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
86  * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
87  * @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
88  * @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
89  * @since 1.0
90  * @version 1.0
91  */
92 int32_t GetSessionHandle(int32_t sessionId, int *handle);
93 
94 /**
95  * @brief Disables the session listener based on the session ID.
96  *
97  * @param sessionId Indicates the unique session ID.
98  *
99  * @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
100  * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
101  * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
102  * @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
103  * @since 1.0
104  * @version 1.0
105  */
106 int32_t DisableSessionListener(int32_t sessionId);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 #endif // DFS_SESSION_H