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;returns an error code otherwise. 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_MEM_ERR</b> if the operation fails due to insufficient memory. 72 * @since 1.0 73 * @version 1.0 74 */ 75 int32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len); 76 77 /** 78 * @brief Obtains the session handle based on the session ID. 79 * 80 * @param sessionId Indicates the unique session ID. 81 * @param handle Indicates the pointer to the buffer that stores the session handle. 82 * 83 * @return Returns <b>SOFTBUS_OK</b> if the operation is successful;returns an error code otherwise. 84 * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 85 * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported. 86 * @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory. 87 * @since 1.0 88 * @version 1.0 89 */ 90 int32_t GetSessionHandle(int32_t sessionId, int *handle); 91 92 /** 93 * @brief Disables the session listener based on the session ID. 94 * 95 * @param sessionId Indicates the unique session ID. 96 * 97 * @return Returns <b>SOFTBUS_OK</b> if the operation is successful;returns an error code otherwise. 98 * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 99 * @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported. 100 * @since 1.0 101 * @version 1.0 102 */ 103 int32_t DisableSessionListener(int32_t sessionId); 104 105 #ifdef __cplusplus 106 } 107 #endif 108 #endif // DFS_SESSION_H