mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 16:59:54 +00:00
feat:Interface optimization as a later backup file
Signed-off-by: wangyipeng <wangyipeng11@huawei.com>
This commit is contained in:
parent
22cf48d032
commit
d400695f98
111
interfaces/inner_kits/transport_socket/dfs_session.h
Normal file
111
interfaces/inner_kits/transport_socket/dfs_session.h
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup SoftBus
|
||||
* @{
|
||||
*
|
||||
* @brief Provides secure, high-speed communications between devices.
|
||||
*
|
||||
* This module implements unified distributed communication management of nearby devices and provides link-independent
|
||||
* device discovery and transmission interfaces to support service publishing and data transmission.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file dfs_session.h
|
||||
*
|
||||
* @brief Declare functions and constants for the distributed file service of DSoftBus. The functions can be used to:
|
||||
* <ul>
|
||||
* <li>Obtain the session key and session handle.</li>
|
||||
* <li>Disable listening for the distributed file service. </li>
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef DFS_SESSION_H
|
||||
#define DFS_SESSION_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Defines the length of the session key, including the terminating null character <b>\0</b>.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define SESSION_KEY_LEN 32
|
||||
|
||||
/**
|
||||
* @example dfs_demo.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Obtains the session key based on the session ID.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param key Indicates the pointer to the buffer that stores the session key.
|
||||
* @param len Indicates the length of the buffer.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
|
||||
* @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
|
||||
* @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Obtains the session handle based on the session ID.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param handle Indicates the pointer to the buffer that stores the session handle.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
|
||||
* @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
|
||||
* @return Returns <b>SOFTBUS_MEM_ERR</b> if the operation fails due to insufficient memory.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t GetSessionHandle(int32_t sessionId, int *handle);
|
||||
|
||||
/**
|
||||
* @brief Disables the session listener based on the session ID.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful.
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_TRANS_FUNC_NOT_SUPPORT</b> if the session ID is not supported.
|
||||
* @return Returns <b>SOFTBUS_ERR</b> if an error occurs in the internal processing of DSoftBus.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t DisableSessionListener(int32_t sessionId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // DFS_SESSION_H
|
85
interfaces/inner_kits/transport_socket/inner_session.h
Normal file
85
interfaces/inner_kits/transport_socket/inner_session.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup SoftBus
|
||||
* @{
|
||||
*
|
||||
* @brief Provides secure, high-speed communications between devices.
|
||||
*
|
||||
* This module implements unified distributed communication management of nearby devices and provides link-independent
|
||||
* device discovery and transmission interfaces to support service publishing and data transmission.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file inner_session.h
|
||||
*
|
||||
* @brief Declares the functions for DSoftBus identity authentication. The functions can be used to:
|
||||
* <ul>
|
||||
* <li>Open an identity authentication session.</li>
|
||||
* <li>Send an authentication success notification.</li>
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#ifndef INNER_SESSION_H
|
||||
#define INNER_SESSION_H
|
||||
|
||||
#include "softbus_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @example openauthsession_demo.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Opens a session for identity authentication.
|
||||
*
|
||||
* @param sessionName Indicates the pointer to the session name for identity authentication.
|
||||
* The session name uniquely identifies a session service. The value cannot be empty or exceed 256 characters.
|
||||
* @param addrInfo Indicates the pointer to the address information for the connection between devices.
|
||||
* @param num Indicates the number of device connection records.
|
||||
* @param mixAddr Indicates the pointer to the connection address information.
|
||||
* If the address information passed by <b>addrInfo</b> is invalid, this parameter can be used to obtain the connection information.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>INVALID_SESSION_ID</b> if the session ID is invalid.
|
||||
* @return Returns the session ID (an integer greater than <b>0</b>) if the operation is successful;
|
||||
* return an error code otherwise.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo, int num, const char *mixAddr);
|
||||
|
||||
/**
|
||||
* @brief Notifies the upper-layer service of the identity authentication success.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void NotifyAuthSuccess(int sessionId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
514
interfaces/kits/common_socket/softbus_common.h
Normal file
514
interfaces/kits/common_socket/softbus_common.h
Normal file
@ -0,0 +1,514 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup SoftBus
|
||||
* @{
|
||||
*
|
||||
* @brief Provides high-speed, secure communication between devices.
|
||||
*
|
||||
* This module implements unified distributed communication capability management between nearby devices, and provides
|
||||
* link-independent device discovery and transmission interfaces to support service publishing and data transmission.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @file softbus_common.h
|
||||
*
|
||||
* @brief Declares common APIs for the Intelligent Soft Bus.
|
||||
*
|
||||
* This file provides common functions and constants for each submodule of the Intelligent Soft Bus, including: \n
|
||||
*
|
||||
* <ul>
|
||||
* <li>Constants such as the network ID length</li>
|
||||
* <li>Functions such as that for initializing the Intelligent Soft Bus client</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef SOFTBUS_CLIENT_COMMON_H
|
||||
#define SOFTBUS_CLIENT_COMMON_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Permission of softbus component
|
||||
*
|
||||
* @since 3.0
|
||||
* @version 3.0
|
||||
*/
|
||||
#define OHOS_PERMISSION_DISTRIBUTED_DATASYNC "ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
#define OHOS_PERMISSION_DISTRIBUTED_SOFTBUS_CENTER "ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"
|
||||
|
||||
/**
|
||||
* @brief Indicates the length of the Bluetooth device MAC address in string format,
|
||||
* including the terminating null character <b>\0</b>.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define BT_MAC_LEN 18
|
||||
|
||||
/**
|
||||
* @brief Indicates the length of the network ID string, including the terminating null character <b>\0</b>.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define NETWORK_ID_BUF_LEN 65
|
||||
|
||||
/**
|
||||
* @brief Indicates the length of the UDID string, including the terminating null character <b>\0</b>.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define UDID_BUF_LEN 65
|
||||
|
||||
/**
|
||||
* @brief Indicates the length of the UDID hash value.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define UDID_HASH_LEN 32
|
||||
|
||||
/**
|
||||
* @brief Indicates the length of the UUID string, including the terminating null character <b>\0</b>.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define UUID_BUF_LEN 65
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of an IP address in string format,
|
||||
* including the terminating null character <b>\0</b>. IPv6 addresses are supported.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define IP_STR_MAX_LEN 46
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the account hash code in <b>IDiscoveryCallback</b>.
|
||||
*
|
||||
*/
|
||||
#define MAX_ACCOUNT_HASH_LEN 96
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the hash code in HEX calculated by SHA-256.
|
||||
*
|
||||
*/
|
||||
#define SHA_256_HASH_LEN 32
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the hash code in string format calculated by SHA-256,
|
||||
* including the terminating null character <b>\0</b>.
|
||||
*
|
||||
*/
|
||||
#define SHA_256_HEX_HASH_LEN 65
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the capability data in <b>PublishInfo</b> and <b>SubscribeInfo</b>.
|
||||
*
|
||||
*/
|
||||
#define MAX_CAPABILITYDATA_LEN 513
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the custom data in <b>IDiscoveryCallback</b>.
|
||||
*
|
||||
*/
|
||||
#define DISC_MAX_CUST_DATA_LEN 219
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum number of capabilities contained in the bitmap in <b>IDiscoveryCallback</b>.
|
||||
*
|
||||
*/
|
||||
#define DISC_MAX_CAPABILITY_NUM 2
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the device name in <b>IDiscoveryCallback</b>.
|
||||
*
|
||||
*/
|
||||
#define DISC_MAX_DEVICE_NAME_LEN 65
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the device ID in <b>IDiscoveryCallback</b>.
|
||||
*
|
||||
*/
|
||||
#define DISC_MAX_DEVICE_ID_LEN 96
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the network commmon length <b>IDiscoveryCallback</b>.
|
||||
*
|
||||
*/
|
||||
#define LNN_COMMON_LEN 4
|
||||
|
||||
/**
|
||||
* @brief Indicates the short hash length of the networkId.
|
||||
*
|
||||
*/
|
||||
#define NODEID_SHORT_HASH_LEN 6
|
||||
|
||||
/**
|
||||
* @brief Indicates the short hash length of the udid.
|
||||
*
|
||||
*/
|
||||
#define UDID_SHORT_HASH_LEN 6
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the device database status in <b>INodeStateCb</b>.
|
||||
*
|
||||
*/
|
||||
#define DATA_CHANGE_FLAG_BUF_LEN 2
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the node address.
|
||||
*
|
||||
*/
|
||||
#define SHORT_ADDRESS_MAX_LEN 20
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum num of the node status.
|
||||
*
|
||||
*/
|
||||
#define NODE_STATUS_MAX_NUM 32
|
||||
/**
|
||||
* @brief Enumerates {@link ConnectionAddrType} types of a device that is added to a LNN.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
CONNECTION_ADDR_WLAN = 0, /**< WLAN */
|
||||
CONNECTION_ADDR_BR, /**< BR */
|
||||
CONNECTION_ADDR_BLE, /**< BLE */
|
||||
CONNECTION_ADDR_ETH, /**< Ethernet */
|
||||
CONNECTION_ADDR_SESSION, /**< SESSION */
|
||||
CONNECTION_ADDR_MAX /**< Invalid type */
|
||||
} ConnectionAddrType;
|
||||
|
||||
/**
|
||||
* @brief Enumerates {@link BleProtocolType} types of ble connection type
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
BLE_PROTOCOL_ANY = -1,
|
||||
BLE_GATT = 0,
|
||||
BLE_COC,
|
||||
BLE_PROTOCOL_MAX
|
||||
} BleProtocolType;
|
||||
|
||||
/**
|
||||
* @brief Defines the address of a device that is added to a LNN.
|
||||
* For details, see {@link ConnectionAddr}.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
/**< Address type. This field is used to explain the <b>info</b> field. */
|
||||
ConnectionAddrType type;
|
||||
/**< Connection address information */
|
||||
union {
|
||||
/**< BR address */
|
||||
struct BrAddr {
|
||||
char brMac[BT_MAC_LEN]; /**< BR MAC address in string format */
|
||||
} br;
|
||||
/**< BLE address */
|
||||
struct BleAddr {
|
||||
BleProtocolType protocol;
|
||||
char bleMac[BT_MAC_LEN]; /**< BLE MAC address in string format */
|
||||
uint8_t udidHash[UDID_HASH_LEN]; /**< udid hash value */
|
||||
int32_t psm;
|
||||
} ble;
|
||||
/**< IPv4 or IPv6 address */
|
||||
struct IpAddr {
|
||||
/**
|
||||
* IP address in string format. It can be an IPv4 address written in dotted decimal notation
|
||||
* or an IPv6 address written in hexadecimal colon-separated notation.
|
||||
*/
|
||||
char ip[IP_STR_MAX_LEN];
|
||||
uint16_t port; /**< Port number represented by the host byte order */
|
||||
} ip;
|
||||
/**< Session address */
|
||||
struct SessionAddr {
|
||||
int32_t sessionId; /**< Session Id in int format */
|
||||
int32_t channelId; /**< Channel Id in int format */
|
||||
int32_t type; /**< Session type in int format */
|
||||
} session;
|
||||
} info;
|
||||
char peerUid[MAX_ACCOUNT_HASH_LEN];
|
||||
} ConnectionAddr;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the modes in which services are published.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
/* Passive */
|
||||
DISCOVER_MODE_PASSIVE = 0x55,
|
||||
/* Proactive */
|
||||
DISCOVER_MODE_ACTIVE = 0xAA
|
||||
} DiscoverMode;
|
||||
|
||||
/**
|
||||
* @brief Enumerates media, such as Bluetooth, Wi-Fi, and USB, used for publishing services.
|
||||
*
|
||||
* Currently, only <b>COAP</b> is supported.
|
||||
* When <b>AUTO</b> is selected, all the supported media will be called automatically.
|
||||
*/
|
||||
typedef enum {
|
||||
/** Automatic medium selection */
|
||||
AUTO = 0,
|
||||
/** Bluetooth */
|
||||
BLE = 1,
|
||||
/** Wi-Fi */
|
||||
COAP = 2,
|
||||
/** USB */
|
||||
USB = 3,
|
||||
/** HiLink */
|
||||
COAP1 = 4,
|
||||
MEDIUM_BUTT
|
||||
} ExchangeMedium;
|
||||
|
||||
/**
|
||||
* @brief Enumerates frequencies for publishing services.
|
||||
*
|
||||
* This enumeration applies only to Bluetooth and is not supported currently.
|
||||
*/
|
||||
typedef enum {
|
||||
/** Low */
|
||||
LOW = 0,
|
||||
/** Medium */
|
||||
MID = 1,
|
||||
/** High */
|
||||
HIGH = 2,
|
||||
/** Super-high */
|
||||
SUPER_HIGH = 3,
|
||||
FREQ_BUTT
|
||||
} ExchangeFreq;
|
||||
|
||||
/**
|
||||
* @brief Enumerates supported capabilities published by a device.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
/** MeeTime */
|
||||
HICALL_CAPABILITY_BITMAP = 0,
|
||||
/** Video reverse connection in the smart domain */
|
||||
PROFILE_CAPABILITY_BITMAP = 1,
|
||||
/** Gallery in Vision */
|
||||
HOMEVISIONPIC_CAPABILITY_BITMAP = 2,
|
||||
/** cast+ */
|
||||
CASTPLUS_CAPABILITY_BITMAP,
|
||||
/** Input method in Vision */
|
||||
AA_CAPABILITY_BITMAP,
|
||||
/** Device virtualization tool package */
|
||||
DVKIT_CAPABILITY_BITMAP,
|
||||
/** Distributed middleware */
|
||||
DDMP_CAPABILITY_BITMAP,
|
||||
/** Osd capability */
|
||||
OSD_CAPABILITY_BITMAP,
|
||||
/**Share capability */
|
||||
SHARE_CAPABILITY_BITMAP
|
||||
} DataBitMap;
|
||||
|
||||
/**
|
||||
* @brief Defines the mapping between supported capabilities and bitmaps.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
/** Bitmaps. For details, see {@link DataBitMap}. */
|
||||
DataBitMap bitmap;
|
||||
/** Capability. For details, see {@link g_capabilityMap}. */
|
||||
char *capability;
|
||||
} CapabilityMap;
|
||||
|
||||
/**
|
||||
* @brief Defines the mapping between supported capabilities and bitmaps.
|
||||
*
|
||||
*/
|
||||
static const CapabilityMap g_capabilityMap[] = {
|
||||
{HICALL_CAPABILITY_BITMAP, (char *)"hicall"},
|
||||
{PROFILE_CAPABILITY_BITMAP, (char *)"profile"},
|
||||
{HOMEVISIONPIC_CAPABILITY_BITMAP, (char *)"homevisionPic"},
|
||||
{CASTPLUS_CAPABILITY_BITMAP, (char *)"castPlus"},
|
||||
{AA_CAPABILITY_BITMAP, (char *)"aaCapability"},
|
||||
{DVKIT_CAPABILITY_BITMAP, (char *)"dvKit"},
|
||||
{DDMP_CAPABILITY_BITMAP, (char *)"ddmpCapability"},
|
||||
{OSD_CAPABILITY_BITMAP, (char *)"osdCapability"},
|
||||
{SHARE_CAPABILITY_BITMAP, (char *)"share"},
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines service publishing information.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
/** Service ID */
|
||||
int publishId;
|
||||
/** Discovery mode for service publishing. For details, see {@link Discovermode}. */
|
||||
DiscoverMode mode;
|
||||
/** Service publishing medium. For details, see {@link ExchangeMedium}. */
|
||||
ExchangeMedium medium;
|
||||
/** Service publishing frequency. For details, see {@link ExchangeFreq}. */
|
||||
ExchangeFreq freq;
|
||||
/** Service publishing capabilities. For details, see {@link g_capabilityMap}. */
|
||||
const char *capability;
|
||||
/** Capability data for service publishing, MUST be c-string format. */
|
||||
unsigned char *capabilityData;
|
||||
/** Maximum length of the capability data for service publishing (512 bytes) */
|
||||
unsigned int dataLen;
|
||||
/** Whether the device should be ranged by discoverers.*/
|
||||
bool ranging;
|
||||
} PublishInfo;
|
||||
|
||||
/**
|
||||
* @brief Defines service subscription information.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
/** Service ID */
|
||||
int subscribeId;
|
||||
/** Discovery mode for service subscription. For details, see {@link Discovermode}. */
|
||||
DiscoverMode mode;
|
||||
/** Service subscription medium. For details, see {@link ExchangeMedium}. */
|
||||
ExchangeMedium medium;
|
||||
/** Service subscription frequency. For details, see {@link ExchangeFreq}. */
|
||||
ExchangeFreq freq;
|
||||
/** only find the device with the same account */
|
||||
bool isSameAccount;
|
||||
/** find the sleeping devices */
|
||||
bool isWakeRemote;
|
||||
/** Service subscription capability. For details, see {@link g_capabilityMap}. */
|
||||
const char *capability;
|
||||
/** Capability data for service subscription, MUST be c-string format. */
|
||||
unsigned char *capabilityData;
|
||||
/** Maximum length of the capability data for service subscription (512 bytes) */
|
||||
unsigned int dataLen;
|
||||
} SubscribeInfo;
|
||||
|
||||
/**
|
||||
* @brief Enumerates single heartbeat cycle parameter.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
/**< Heartbeat interval 30 sec */
|
||||
HIGH_FREQ_CYCLE = 30,
|
||||
/**< Heartbeat interval 60 sec */
|
||||
MID_FREQ_CYCLE = 60,
|
||||
/**< Heartbeat interval 5 * 60 sec */
|
||||
LOW_FREQ_CYCLE = 5 * 60,
|
||||
} ModeCycle;
|
||||
|
||||
/**
|
||||
* @brief Enumerates duration of heartbeat keeping alive parameter.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
/**< Heartbeat continues for 60 sec */
|
||||
DEFAULT_DURATION = 60,
|
||||
/**< Heartbeat continues for 10 * 60 sec. */
|
||||
NORMAL_DURATION = 10 * 60,
|
||||
/**< Heartbeat continues for 30 * 60 sec. */
|
||||
LONG_DURATION = 30 * 60,
|
||||
} ModeDuration;
|
||||
|
||||
/**
|
||||
* @brief Enumerates device types.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
/* Smart speaker */
|
||||
SMART_SPEAKER = 0x00,
|
||||
/* PC */
|
||||
DESKTOP_PC,
|
||||
/* Laptop */
|
||||
LAPTOP,
|
||||
/* Mobile phone */
|
||||
SMART_PHONE,
|
||||
/* Tablet */
|
||||
SMART_PAD,
|
||||
/* Smart watch */
|
||||
SMART_WATCH,
|
||||
/* Smart car */
|
||||
SMART_CAR,
|
||||
/* Kids' watch */
|
||||
CHILDREN_WATCH,
|
||||
/* Smart TV */
|
||||
SMART_TV,
|
||||
} DeviceType;
|
||||
|
||||
/**
|
||||
* @brief Defines the device information returned by <b>IDiscoveryCallback</b>.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
/** Device ID. Its maximum length is specified by {@link DISC_MAX_DEVICE_ID_LEN}. */
|
||||
char devId[DISC_MAX_DEVICE_ID_LEN];
|
||||
/** Account hash code. Its maximum length is specified by {@link MAX_ACCOUNT_HASH_LEN}. */
|
||||
char accountHash[MAX_ACCOUNT_HASH_LEN];
|
||||
/** Device type. For details, see {@link DeviceType}. */
|
||||
DeviceType devType;
|
||||
/** Device name. Its maximum length is specified by {@link DISC_MAX_DEVICE_NAME_LEN}. */
|
||||
char devName[DISC_MAX_DEVICE_NAME_LEN];
|
||||
/** Device Online Status **/
|
||||
bool isOnline;
|
||||
/** Number of available connections */
|
||||
unsigned int addrNum;
|
||||
/** Connection information. For details, see {@link ConnectionAddr}. */
|
||||
ConnectionAddr addr[CONNECTION_ADDR_MAX];
|
||||
/** Number of capabilities */
|
||||
unsigned int capabilityBitmapNum;
|
||||
/** Device capability bitmap.
|
||||
* The maximum number of capabilities in the bitmap is specified by {@link DISC_MAX_CAPABILITY_NUM}.
|
||||
*/
|
||||
unsigned int capabilityBitmap[DISC_MAX_CAPABILITY_NUM];
|
||||
/** Custom data. Its length is specified by {@link DISC_MAX_CUST_DATA_LEN}. */
|
||||
char custData[DISC_MAX_CUST_DATA_LEN];
|
||||
/** The distance of discovered device, in centimeters(cm)*/
|
||||
int32_t range;
|
||||
} DeviceInfo;
|
||||
|
||||
/**
|
||||
* @brief Defines device additional info used by inner
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
/** medium which describe the device found by. */
|
||||
ExchangeMedium medium;
|
||||
} InnerDeviceInfoAddtions;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/** @} */
|
390
interfaces/kits/common_socket/softbus_error_code.h
Normal file
390
interfaces/kits/common_socket/softbus_error_code.h
Normal file
@ -0,0 +1,390 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup SoftBus
|
||||
* @{
|
||||
*
|
||||
* @brief Provides high-speed, secure communication between devices.
|
||||
*
|
||||
* This module implements unified distributed communication capability management between nearby devices, and provides
|
||||
* link-independent device discovery and transmission interfaces to support service publishing and data transmission.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @file softbus_error_code.h
|
||||
*
|
||||
* @brief Declares error code
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef SOFTBUS_ERROR_CODE_H
|
||||
#define SOFTBUS_ERROR_CODE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum SoftBusModuleBase {
|
||||
DISCOVER_BASE_ERROR = 100000,
|
||||
CONNECT_BASE_ERROR = 200000,
|
||||
NETWORK_BASE_ERROR = 300000,
|
||||
TRANSPORT_BASE_ERROR = 400000,
|
||||
CONNECT_LINK_TYPE_BR = ((1 << 24) & 0xFF000000),
|
||||
};
|
||||
|
||||
enum SoftBusSubModule {
|
||||
SOFTBUS_MODULE_CODE = 203 << 21,
|
||||
COMMON_SUB_MODULE_CODE = 1 << 16,
|
||||
DISCOVER_SUB_MODULE_CODE = 10 << 16,
|
||||
CONNECT_SUB_MODULE_CODE = 11 << 16,
|
||||
NETWORK_SUB_MODULE_CODE = 12 << 16,
|
||||
TRANSPORT_SUB_MODULE_CODE = 13 << 16,
|
||||
BR_LINK_SUB_MODULE_CODE = 14 << 10,
|
||||
FAIL_RET_EX = 2,
|
||||
};
|
||||
|
||||
enum SoftBusModule {
|
||||
SOFTBUS_MOD_COMMON = 0,
|
||||
SOFTBUS_MOD_PLUGIN,
|
||||
SOFTBUS_MOD_TRANS,
|
||||
SOFTBUS_MOD_AUTH,
|
||||
SOFTBUS_MOD_LNN,
|
||||
SOFTBUS_MOD_CONNECT,
|
||||
SOFTBUS_MOD_DISCOVERY,
|
||||
SOFTBUS_MOD_PUBLIC,
|
||||
};
|
||||
#define SOFTBUS_ERRNO(module) ((0xF << 28) | ((1 << (module)) << 16))
|
||||
|
||||
enum SoftBusErrNo {
|
||||
/* errno begin: 0xF0010000 */
|
||||
SOFTBUS_COMMOM_ERR_BASE = SOFTBUS_ERRNO(SOFTBUS_MOD_COMMON),
|
||||
SOFTBUS_TIMOUT,
|
||||
SOFTBUS_INVALID_PARAM,
|
||||
SOFTBUS_MEM_ERR,
|
||||
SOFTBUS_NOT_IMPLEMENT,
|
||||
SOFTBUS_NO_URI_QUERY_KEY,
|
||||
SOFTBUS_NO_INIT,
|
||||
SOFTBUS_CREATE_JSON_ERR,
|
||||
SOFTBUS_PARSE_JSON_ERR,
|
||||
SOFTBUS_PERMISSION_DENIED,
|
||||
SOFTBUS_ACCESS_TOKEN_DENIED,
|
||||
SOFTBUS_MALLOC_ERR,
|
||||
SOFTBUS_STRCPY_ERR,
|
||||
SOFTBUS_ENCRYPT_ERR,
|
||||
SOFTBUS_DECRYPT_ERR,
|
||||
SOFTBUS_INVALID_SESS_OPCODE,
|
||||
SOFTBUS_INVALID_NUM,
|
||||
SOFTBUS_SERVER_NAME_REPEATED,
|
||||
SOFTBUS_TCP_SOCKET_ERR,
|
||||
SOFTBUS_LOCK_ERR,
|
||||
SOFTBUS_GET_REMOTE_UUID_ERR,
|
||||
SOFTBUS_NO_ENOUGH_DATA,
|
||||
SOFTBUS_INVALID_DATA_HEAD,
|
||||
SOFTBUS_INVALID_FD,
|
||||
SOFTBUS_FILE_ERR,
|
||||
SOFTBUS_DATA_NOT_ENOUGH,
|
||||
SOFTBUS_SLICE_ERROR,
|
||||
SOFTBUS_ALREADY_EXISTED,
|
||||
SOFTBUS_GET_CONFIG_VAL_ERR,
|
||||
SOFTBUS_PEER_PROC_ERR,
|
||||
SOFTBUS_NOT_FIND,
|
||||
SOFTBUS_ALREADY_TRIGGERED,
|
||||
SOFTBUS_FILE_BUSY,
|
||||
SOFTBUS_IPC_ERR,
|
||||
|
||||
SOFTBUS_INVALID_PKGNAME,
|
||||
SOFTBUS_FUNC_NOT_SUPPORT,
|
||||
SOFTBUS_SERVER_NOT_INIT,
|
||||
SOFTBUS_SERVER_NAME_USED,
|
||||
|
||||
/* errno begin: 0xF0020000 */
|
||||
SOFTBUS_PLUGIN_ERR_BASE = SOFTBUS_ERRNO(SOFTBUS_MOD_PLUGIN),
|
||||
|
||||
/* errno begin: 0xF0040000 */
|
||||
SOFTBUS_TRANS_ERR_BASE = SOFTBUS_ERRNO(SOFTBUS_MOD_TRANS),
|
||||
SOFTBUS_TRANS_INVALID_SESSION_ID,
|
||||
SOFTBUS_TRANS_INVALID_SESSION_NAME,
|
||||
SOFTBUS_TRANS_INVALID_CHANNEL_TYPE,
|
||||
SOFTBUS_TRANS_INVALID_CLOSE_CHANNEL_ID,
|
||||
SOFTBUS_TRANS_BUSINESS_TYPE_NOT_MATCH,
|
||||
SOFTBUS_TRANS_SESSION_REPEATED,
|
||||
SOFTBUS_TRANS_SESSION_CNT_EXCEEDS_LIMIT,
|
||||
SOFTBUS_TRANS_SESSIONSERVER_NOT_CREATED,
|
||||
SOFTBUS_TRANS_SESSION_OPENING,
|
||||
SOFTBUS_TRANS_GET_LANE_INFO_ERR,
|
||||
SOFTBUS_TRANS_CREATE_CHANNEL_ERR,
|
||||
SOFTBUS_TRANS_INVALID_DATA_LENGTH,
|
||||
SOFTBUS_TRANS_FUNC_NOT_SUPPORT,
|
||||
SOFTBUS_TRANS_OPEN_AUTH_CHANNANEL_FAILED,
|
||||
SOFTBUS_TRANS_GET_P2P_INFO_FAILED,
|
||||
SOFTBUS_TRANS_OPEN_AUTH_CONN_FAILED,
|
||||
|
||||
SOFTBUS_TRANS_PROXY_PACKMSG_ERR,
|
||||
SOFTBUS_TRANS_PROXY_SENDMSG_ERR,
|
||||
SOFTBUS_TRANS_PROXY_SEND_CHANNELID_INVALID,
|
||||
SOFTBUS_TRANS_PROXY_CHANNLE_STATUS_INVALID,
|
||||
SOFTBUS_TRANS_PROXY_DEL_CHANNELID_INVALID,
|
||||
SOFTBUS_TRANS_PROXY_SESS_ENCRYPT_ERR,
|
||||
SOFTBUS_TRANS_PROXY_INVALID_SLICE_HEAD,
|
||||
SOFTBUS_TRANS_PROXY_ASSEMBLE_PACK_NO_INVALID,
|
||||
SOFTBUS_TRANS_PROXY_ASSEMBLE_PACK_EXCEED_LENGTH,
|
||||
SOFTBUS_TRANS_PROXY_ASSEMBLE_PACK_DATA_NULL,
|
||||
|
||||
SOFTBUS_TRANS_UDP_CLOSE_CHANNELID_INVALID,
|
||||
SOFTBUS_TRANS_UDP_SERVER_ADD_CHANNEL_FAILED,
|
||||
SOFTBUS_TRANS_UDP_CLIENT_ADD_CHANNEL_FAILED,
|
||||
SOFTBUS_TRANS_UDP_SERVER_NOTIFY_APP_OPEN_FAILED,
|
||||
SOFTBUS_TRANS_UDP_CLIENT_NOTIFY_APP_OPEN_FAILED,
|
||||
SOFTBUS_TRANS_UDP_START_STREAM_SERVER_FAILED,
|
||||
SOFTBUS_TRANS_UDP_START_STREAM_CLIENT_FAILED,
|
||||
SOFTBUS_TRANS_UDP_SEND_STREAM_FAILED,
|
||||
SOFTBUS_TRANS_UDP_GET_CHANNEL_FAILED,
|
||||
SOFTBUS_TRANS_UDP_CHANNEL_DISABLE,
|
||||
|
||||
SOFTBUS_TRANS_QOS_REPORT_FAILED,
|
||||
SOFTBUS_TRANS_QOS_REPORT_TOO_FREQUENT,
|
||||
|
||||
SOFTBUS_TRANS_SESSION_SERVER_NOINIT,
|
||||
SOFTBUS_TRANS_SESSION_INFO_NOT_FOUND,
|
||||
SOFTBUS_TRANS_SESSION_CREATE_FAILED,
|
||||
SOFTBUS_TRANS_SESSION_ADDPKG_FAILED,
|
||||
SOFTBUS_TRANS_SESSION_SET_CHANNEL_FAILED,
|
||||
SOFTBUS_TRANS_SESSION_NO_ENABLE,
|
||||
SOFTBUS_TRANS_SESSION_GROUP_INVALID,
|
||||
SOFTBUS_TRANS_SESSION_NAME_NO_EXIST,
|
||||
SOFTBUS_TRANS_SESSION_GET_CHANNEL_FAILED,
|
||||
|
||||
SOFTBUS_TRANS_PROXY_REMOTE_NULL,
|
||||
SOFTBUS_TRANS_PROXY_WRITETOKEN_FAILED,
|
||||
SOFTBUS_TRANS_PROXY_WRITECSTRING_FAILED,
|
||||
SOFTBUS_TRANS_PROXY_WRITERAWDATA_FAILED,
|
||||
SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED,
|
||||
SOFTBUS_TRANS_PROXY_SEND_REQUEST_FAILED,
|
||||
SOFTBUS_TRANS_PROXY_INVOKE_FAILED,
|
||||
SOFTBUS_TRANS_PROXY_CHANNEL_NOT_FOUND,
|
||||
|
||||
SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT,
|
||||
SOFTBUS_TRANS_FILE_LISTENER_NOT_INIT,
|
||||
SOFTBUS_TRANS_STREAM_ONLY_UDP_CHANNEL,
|
||||
SOFTBUS_TRANS_CHANNEL_TYPE_INVALID,
|
||||
SOFTBUS_TRANS_TDC_CHANNEL_NOT_FOUND,
|
||||
SOFTBUS_TRANS_TDC_CHANNEL_ALREADY_PENDING,
|
||||
SOFTBUS_TRANS_TDC_PENDINGLIST_NOT_FOUND,
|
||||
SOFTBUS_TRANS_AUTH_CHANNEL_NOT_FOUND,
|
||||
SOFTBUS_TRANS_NET_STATE_CHANGED,
|
||||
SOFTBUS_TRANS_HANDSHAKE_TIMEOUT,
|
||||
SOFTBUS_TRANS_HANDSHAKE_ERROR,
|
||||
SOFTBUS_TRANS_PEER_SESSION_NOT_CREATED,
|
||||
SOFTBUS_TRANS_PROXY_DISCONNECTED,
|
||||
SOFTBUS_TRANS_AUTH_NOTALLOW_OPENED,
|
||||
SOFTBUS_TRANS_PROXY_ERROR_APP_TYPE,
|
||||
SOFTBUS_TRANS_PROXY_CONN_REPEAT,
|
||||
SOFTBUS_TRANS_PROXY_CONN_ADD_REF_FAILED,
|
||||
|
||||
/* errno begin: 0xF0080000 */
|
||||
SOFTBUS_AUTH_ERR_BASE = SOFTBUS_ERRNO(SOFTBUS_MOD_AUTH),
|
||||
SOFTBUS_AUTH_INIT_FAIL,
|
||||
SOFTBUS_AUTH_CONN_FAIL,
|
||||
SOFTBUS_AUTH_CONN_TIMEOUT,
|
||||
SOFTBUS_AUTH_DEVICE_DISCONNECTED,
|
||||
SOFTBUS_AUTH_SYNC_DEVID_FAIL,
|
||||
SOFTBUS_AUTH_UNPACK_DEVID_FAIL,
|
||||
SOFTBUS_AUTH_HICHAIN_AUTH_FAIL,
|
||||
SOFTBUS_AUTH_HICHAIN_PROCESS_FAIL,
|
||||
SOFTBUS_AUTH_HICHAIN_TRANSMIT_FAIL,
|
||||
SOFTBUS_AUTH_HICHAIN_AUTH_ERROR,
|
||||
SOFTBUS_AUTH_HICHAIN_NOT_TRUSTED,
|
||||
SOFTBUS_AUTH_SYNC_DEVINFO_FAIL,
|
||||
SOFTBUS_AUTH_UNPACK_DEVINFO_FAIL,
|
||||
SOFTBUS_AUTH_SEND_FAIL,
|
||||
SOFTBUS_AUTH_TIMEOUT,
|
||||
SOFTBUS_AUTH_NOT_FOUND,
|
||||
SOFTBUS_AUTH_INNER_ERR,
|
||||
|
||||
/* errno begin: 0xF0100000 */
|
||||
SOFTBUS_NETWORK_ERR_BASE = SOFTBUS_ERRNO(SOFTBUS_MOD_LNN),
|
||||
SOFTBUS_NETWORK_CONN_FSM_DEAD,
|
||||
SOFTBUS_NETWORK_JOIN_CANCELED,
|
||||
SOFTBUS_NETWORK_JOIN_LEAVING,
|
||||
SOFTBUS_NETWORK_JOIN_TIMEOUT,
|
||||
SOFTBUS_NETWORK_UNPACK_DEV_INFO_FAILED,
|
||||
SOFTBUS_NETWORK_DEV_NOT_TRUST,
|
||||
SOFTBUS_NETWORK_LEAVE_OFFLINE,
|
||||
SOFTBUS_NETWORK_AUTH_DISCONNECT,
|
||||
SOFTBUS_NETWORK_TIME_SYNC_HANDSHAKE_ERR, // time sync channel pipe broken
|
||||
SOFTBUS_NETWORK_TIME_SYNC_HANDSHAKE_TIMEOUT, // timeout during handshake
|
||||
SOFTBUS_NETWORK_TIME_SYNC_TIMEOUT, // timeout during sync
|
||||
SOFTBUS_NETWORK_TIME_SYNC_INTERFERENCE, // interference
|
||||
SOFTBUS_NETWORK_HEARTBEAT_REPEATED,
|
||||
SOFTBUS_NETWORK_HEARTBEAT_UNTRUSTED,
|
||||
SOFTBUS_NETWORK_HEARTBEAT_EMPTY_LIST,
|
||||
SOFTBUS_NETWORK_NODE_OFFLINE,
|
||||
SOFTBUS_NETWORK_NODE_DIRECT_ONLINE,
|
||||
SOFTBUS_NETWORK_NOT_INIT,
|
||||
SOFTBUS_NETWORK_LOOPER_ERR,
|
||||
SOFTBUS_NETWORK_AUTH_TCP_ERR,
|
||||
SOFTBUS_NETWORK_AUTH_BLE_ERR,
|
||||
SOFTBUS_NETWORK_AUTH_BR_ERR,
|
||||
SOFTBUS_NETWORK_GET_ALL_NODE_INFO_ERR,
|
||||
SOFTBUS_NETWORK_GET_LOCAL_NODE_INFO_ERR,
|
||||
SOFTBUS_NETWORK_NODE_KEY_INFO_ERR,
|
||||
SOFTBUS_NETWORK_ACTIVE_META_NODE_ERR,
|
||||
SOFTBUS_NETWORK_DEACTIVE_META_NODE_ERR,
|
||||
SOFTBUS_NETWORK_GET_META_NODE_INFO_ERR,
|
||||
|
||||
/* errno begin: 0xF0200000 */
|
||||
SOFTBUS_CONN_ERR_BASE = SOFTBUS_ERRNO(SOFTBUS_MOD_CONNECT),
|
||||
SOFTBUS_CONN_FAIL,
|
||||
SOFTBUS_CONN_MANAGER_TYPE_NOT_SUPPORT,
|
||||
SOFTBUS_CONN_MANAGER_OP_NOT_SUPPORT,
|
||||
SOFTBUS_CONN_MANAGER_PKT_LEN_INVALID,
|
||||
SOFTBUS_CONN_MANAGER_LIST_NOT_INIT,
|
||||
SOFTBUS_CONN_INVALID_CONN_TYPE,
|
||||
SOFTBUS_CONNECTION_BASE,
|
||||
SOFTBUS_CONNECTION_ERR_CLOSED,
|
||||
SOFTBUS_CONNECTION_ERR_DRIVER_CONGEST,
|
||||
SOFTBUS_CONNECTION_ERR_SOFTBUS_CONGEST,
|
||||
SOFTBUS_CONNECTION_ERR_CONNID_INVALID,
|
||||
SOFTBUS_CONNECTION_ERR_SENDQUEUE_FULL,
|
||||
|
||||
/* common error for bluetooth medium */
|
||||
SOFTBUS_CONN_BLUETOOTH_OFF,
|
||||
|
||||
SOFTBUS_CONN_BR_INTERNAL_ERR,
|
||||
SOFTBUS_CONN_BR_INVALID_ADDRESS_ERR,
|
||||
SOFTBUS_CONN_BR_CONNECT_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BR_CONNECTION_NOT_EXIST_ERR,
|
||||
SOFTBUS_CONN_BR_CONNECTION_NOT_READY_ERR,
|
||||
SOFTBUS_CONN_BR_CONNECTION_INVALID_SOCKET,
|
||||
SOFTBUS_CONN_BR_UNDERLAY_CONNECT_FAIL,
|
||||
SOFTBUS_CONN_BR_UNDERLAY_WRITE_FAIL,
|
||||
SOFTBUS_CONN_BR_UNDERLAY_SOCKET_CLOSED,
|
||||
SOFTBUS_CONN_BR_UNDERLAY_READ_FAIL,
|
||||
|
||||
SOFTBUS_CONN_BLE_INTERNAL_ERR,
|
||||
SOFTBUS_CONN_BLE_CONNECT_PREVENTED_ERR,
|
||||
SOFTBUS_CONN_BLE_DISCONNECT_DIRECTLY_ERR,
|
||||
SOFTBUS_CONN_BLE_DISCONNECT_WAIT_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BLE_CONNECT_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BLE_EXCHANGE_BASIC_INFO_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BLE_CONNECTION_NOT_EXIST_ERR,
|
||||
SOFTBUS_CONN_BLE_CONNECTION_NOT_READY_ERR,
|
||||
SOFTBUS_CONN_BLE_CLIENT_STATE_UNEXPECTED_ERR,
|
||||
SOFTBUS_CONN_BLE_SERVER_STATE_UNEXPECTED_ERR,
|
||||
SOFTBUS_CONN_BLE_SERVER_START_SERVER_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BLE_SERVER_STOP_SERVER_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_DISCONNECT_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_REGISTER_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_CONNECT_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_CONNECT_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_DISCONNECT_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_DISCONNECT_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_SEARCH_SERVICE_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_SEARCH_SERVICE_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_GET_SERVICE_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_REGISTER_NOTIFICATION_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_REGISTER_NOTIFICATION_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_CONFIGURE_MTU_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_CONFIGURE_MTU_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CLIENT_WRITE_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVER_REGISTER_CALLBACK_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVER_ADD_SERVICE_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVER_ADD_SERVICE_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CHARACTERISTIC_ADD_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CHARACTERISTIC_ADD_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_DESCRIPTOR_ADD_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_DESCRIPTOR_ADD_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVICE_START_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVICE_START_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVICE_STOP_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVICE_STOP_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVICE_DELETE_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVICE_DELETE_FAIL,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_UNKNOWN_SERVICE_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_UNKNOWN_CHARACTERISTIC_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_UNKNOWN_DESCRIPTOR_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_SERVICE_HANDLE_MISMATCH_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_CHARACTERISTIC_HANDLE_MISMATCH_ERR,
|
||||
SOFTBUS_CONN_BLE_UNDERLAY_DESCRIPTOR_HANDLE_MISMATCH_ERR,
|
||||
|
||||
SOFTBUS_CONN_BLE_COC_INTERNAL_ERR,
|
||||
SOFTBUS_CONN_BLE_COC_INVALID_ADDRESS_ERR,
|
||||
SOFTBUS_CONN_BLE_COC_CONNECT_TIMEOUT_ERR,
|
||||
SOFTBUS_CONN_BLE_COC_CONNECTION_NOT_EXIST_ERR,
|
||||
SOFTBUS_CONN_BLE_COC_CONNECTION_NOT_READY_ERR,
|
||||
SOFTBUS_CONN_BLE_COC_CONNECTION_INVALID_SOCKET,
|
||||
SOFTBUS_CONN_BLE_COC_UNDERLAY_CONNECT_FAIL,
|
||||
SOFTBUS_CONN_BLE_COC_UNDERLAY_WRITE_FAIL,
|
||||
SOFTBUS_CONN_BLE_COC_UNDERLAY_SOCKET_CLOSED,
|
||||
SOFTBUS_CONN_BLE_COC_UNDERLAY_READ_FAIL,
|
||||
|
||||
SOFTBUS_BLECONNECTION_REG_GATTS_CALLBACK_FAIL,
|
||||
SOFTBUS_GATTC_INTERFACE_FAILED,
|
||||
|
||||
SOFTBUS_TCPCONNECTION_SOCKET_ERR,
|
||||
SOFTBUS_TCPFD_NOT_IN_TRIGGER,
|
||||
|
||||
/* errno begin: 0xF0400000 */
|
||||
SOFTBUS_DISCOVER_ERR_BASE = SOFTBUS_ERRNO(SOFTBUS_MOD_DISCOVERY),
|
||||
SOFTBUS_DISCOVER_NOT_INIT,
|
||||
SOFTBUS_DISCOVER_INVALID_PKGNAME,
|
||||
SOFTBUS_DISCOVER_SERVER_NO_PERMISSION,
|
||||
SOFTBUS_DISCOVER_MANAGER_NOT_INIT,
|
||||
SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE,
|
||||
SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE,
|
||||
SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE,
|
||||
SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL,
|
||||
SOFTBUS_DISCOVER_MANAGER_CAPABILITY_INVALID,
|
||||
SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM,
|
||||
SOFTBUS_DISCOVER_MANAGER_INVALID_PARAM,
|
||||
SOFTBUS_DISCOVER_MANAGER_INVALID_MEDIUM,
|
||||
SOFTBUS_DISCOVER_MANAGER_INVALID_PKGNAME,
|
||||
SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE,
|
||||
SOFTBUS_DISCOVER_COAP_NOT_INIT,
|
||||
SOFTBUS_DISCOVER_COAP_INIT_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_MERGE_CAP_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_CANCEL_CAP_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_REGISTER_CAP_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_SET_FILTER_CAP_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_REGISTER_DEVICE_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_START_PUBLISH_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_STOP_PUBLISH_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_START_DISCOVER_FAIL,
|
||||
SOFTBUS_DISCOVER_COAP_STOP_DISCOVER_FAIL,
|
||||
|
||||
/* errno begin: 0xF0800000 */
|
||||
SOFTBUS_PUBLIC_ERR_BASE = (-13000),
|
||||
|
||||
/* internal error */
|
||||
SOFTBUS_ERR = (-1),
|
||||
/* softbus ok */
|
||||
SOFTBUS_OK = 0,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* SOFTBUS_ERRCODE_H */
|
774
interfaces/kits/transport_socket/session.h
Normal file
774
interfaces/kits/transport_socket/session.h
Normal file
@ -0,0 +1,774 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup SoftBus
|
||||
* @{
|
||||
*
|
||||
* @brief Provides high-speed, secure communications between devices.
|
||||
*
|
||||
* This module implements unified distributed communication management of
|
||||
* nearby devices, and provides link-independent device discovery and transmission interfaces
|
||||
* to support service publishing and data transmission.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file session.h
|
||||
*
|
||||
* @brief Declares unified data transmission interfaces.
|
||||
*
|
||||
* This file provides data transmission capabilities, including creating and removing a session server,
|
||||
* opening and closing sessions, receiving data, and querying basic session information. \n
|
||||
* You can use the interfaces to transmit data across the nearby devices that are discovered and networked.
|
||||
* \n
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#ifndef SESSION_H
|
||||
#define SESSION_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enumerates the session types.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
TYPE_MESSAGE = 1, /**< Message */
|
||||
TYPE_BYTES, /**< Bytes */
|
||||
TYPE_FILE, /**< File */
|
||||
TYPE_STREAM, /**< Stream */
|
||||
TYPE_BUTT,
|
||||
} SessionType;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the stream types.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
INVALID = -1, /**< Invalid stream type. */
|
||||
RAW_STREAM, /**< Send any segment of a frame each time. */
|
||||
COMMON_VIDEO_STREAM, /**< Send a whole video frame each time. */
|
||||
COMMON_AUDIO_STREAM, /**< Send a whole audio frame each time. */
|
||||
VIDEO_SLICE_STREAM, /**< Slice frame mode. */
|
||||
} StreamType;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the link types.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
LINK_TYPE_WIFI_WLAN_5G = 1, /**< 5 GHz Wi-Fi link */
|
||||
LINK_TYPE_WIFI_WLAN_2G = 2, /**< 2.4 GHz Wi-Fi link */
|
||||
LINK_TYPE_WIFI_P2P = 3, /**< P2P link */
|
||||
LINK_TYPE_BR = 4, /**< BR link */
|
||||
LINK_TYPE_BLE = 5,
|
||||
LINK_TYPE_WIFI_P2P_REUSE = 6,
|
||||
LINK_TYPE_BLE_DIRECT = 7,
|
||||
LINK_TYPE_COC = 8,
|
||||
LINK_TYPE_COC_DIRECT = 9,
|
||||
LINK_TYPE_MAX = 9,
|
||||
} LinkType;
|
||||
|
||||
#define MAX_MAC_LEN 18
|
||||
|
||||
/**
|
||||
* @brief Defines the session attributes.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
int dataType; /**< Session type {@link SessionType} */
|
||||
int linkTypeNum; /**< Number of link types */
|
||||
LinkType linkType[LINK_TYPE_MAX]; /**< Link type {@link LinkType} */
|
||||
/**
|
||||
* @brief Defines the attributes.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
union {
|
||||
/**
|
||||
* @brief Defines the stream attributes.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
struct StreamAttr {
|
||||
int streamType; /**< Stream type {@link StreamType} */
|
||||
} streamAttr;
|
||||
} attr;
|
||||
uint8_t *fastTransData;
|
||||
uint16_t fastTransDataSize;
|
||||
} SessionAttribute;
|
||||
|
||||
/**
|
||||
* @brief Defines the stream data.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
char *buf; /**< Pointer to the buffer for storing the stream data */
|
||||
int bufLen; /**< Length of the buffer */
|
||||
} StreamData;
|
||||
|
||||
/**
|
||||
* @brief Defines the extended stream data.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
int type; /**< Extended data type {@link TransEnumEventType} */
|
||||
int64_t value; /**< Value of the extended data */
|
||||
} TV;
|
||||
|
||||
/**
|
||||
* @brief Defines the frame information for stream transmission.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
int frameType; /**< Frame type, which can be I-frame or P-frame. */
|
||||
int64_t timeStamp; /**< Timestamp. */
|
||||
int seqNum; /**< Sequence number. */
|
||||
int seqSubNum; /**< Sequence number of the slice. */
|
||||
int level; /**< Scalable video coding level. <b>0</b> stands for the base level,
|
||||
<b>1</b> for level 1, and <b>2</b> for level 2. */
|
||||
int bitMap; /**< Bitmap, which indicates the start or end slice of a frame. */
|
||||
int tvCount; /**< Number of scalable tag-values (TVs). */
|
||||
TV *tvList; /**< Pointer to the TV list. */
|
||||
} StreamFrameInfo;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the quality of service (QoS) types.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
QOS_IMPROVE = 0, /**< Improve QoS */
|
||||
QOS_RECOVER = 1, /**< Recover QoS */
|
||||
} QosQuality;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the QoS feedback types.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
TRANS_STREAM_QUALITY_EVENT = 1, /**< Feedback on stream transmission quality */
|
||||
TRANS_CHANNEL_QUALITY_EVENT, /**< Feedback on transmission channel quality */
|
||||
TRANS_CAN_DELAY_EVENT, /**< Feedback on deferrable transmission */
|
||||
TRANS_CANT_DELAY_EVENT, /**< Feedback on non-deferrable transmission */
|
||||
QOS_EVENT_MAX /**< Invalid feedback */
|
||||
} QosEvent;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the stream transmission QoS event types.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_CHANNEL_QUALITY = 1, /**< Wi-Fi channel quality */
|
||||
FRAME_REALTIME_STATUS = 2, /**< Real-time status of frame transmission */
|
||||
BANDWIDTH_ESTIMATE_VALUE = 3, /**< Bandwidth estimation */
|
||||
JITTER_DETECTION_VALUE = 4, /**< Jitter detection */
|
||||
STREAM_TRAFFIC_STASTICS = 5, /**< Stream traffic statistics */
|
||||
} TransEnumEventType;
|
||||
|
||||
/**
|
||||
* @brief Defines the Wi-Fi channel quality.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
int32_t channel; /**< Wi-Fi channel */
|
||||
int32_t score; /**< Wi-Fi channel score */
|
||||
} WifiChannelQuality;
|
||||
|
||||
/**
|
||||
* @brief Defines the frame information.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
int32_t streamId; /**< Stream ID */
|
||||
int32_t seqNum; /**< Sequence number of the frame */
|
||||
int32_t level; /**< Frame layer number */
|
||||
int32_t transStatus; /**< Frame status */
|
||||
int32_t interval; /**< Duration that unsent frames in the queue are cached */
|
||||
} FrameStatus;
|
||||
|
||||
/**
|
||||
* @brief Defines the bandwidth detection information.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t trend; /**< Bandwidth change trend */
|
||||
uint32_t rate; /**< Bandwidth rate */
|
||||
} BandwidthDetection;
|
||||
|
||||
/**
|
||||
* @brief Defines the jitter estimation information.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
int32_t jitterLevel; /**< Estimated network status */
|
||||
uint32_t bufferTime; /**< Required buffer time */
|
||||
} JitterEstimation;
|
||||
|
||||
/**
|
||||
* @brief Defines the stream transmission statistics information.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t statisticsGotTime; /**< Time when the statistics information is obtained */
|
||||
uint64_t periodRecvBits; /**< Number of bits received in a transmission period */
|
||||
uint32_t pktNum; /**< Number of packets */
|
||||
uint32_t periodRecvPkts; /**< Number of packets received in a transmission period */
|
||||
uint32_t periodRecvPktLoss; /**< Number of RX packets lost in a transmission period */
|
||||
uint32_t periodRecvRate; /**< Receive rate in a transmission period, in kbit/s */
|
||||
uint64_t periodRecvRateBps; /**< RX rate in a transmission period, in bit/s */
|
||||
uint32_t periodRtt; /**< Round-trip time (RTT), in ms */
|
||||
|
||||
/**< RX packet loss rate displayed for high precision.
|
||||
For example, if the packet loss rate is 1.10%, the value is <b>110</b>. */
|
||||
uint32_t periodRecvPktLossHighPrecision;
|
||||
uint32_t periodSendLostPkts; /**< Number of TX packets lost in a transmission period */
|
||||
uint32_t periodSendPkts; /**< Number of packets sent in a transmission period */
|
||||
|
||||
/**< TX packet loss rate displayed for high precision.
|
||||
For example, if the packet loss rate is 1.10%, the value is <b>110</b>. */
|
||||
uint32_t periodSendPktLossHighPrecision;
|
||||
uint64_t periodSendBits; /**< Number of bits sent in a transmission period */
|
||||
uint64_t periodSendRateBps; /**< TX rate in a transmission period, in bps */
|
||||
} StreamStatistics;
|
||||
|
||||
/**
|
||||
* @brief Defines the video stream transmission QoS.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
TransEnumEventType type; /**< Stream transmission QoS event type {@link TransEnumEventType} */
|
||||
union {
|
||||
WifiChannelQuality wifiChannelInfo; /**< Wi-Fi channel quality {@link WifiChannelQuality} */
|
||||
FrameStatus frameStatusInfo; /**< Frame information {@link FrameStatus} */
|
||||
BandwidthDetection bandwidthInfo; /**< Bandwidth detection {@link BandwidthDetection} */
|
||||
JitterEstimation jitterInfo; /**< Network jitter estimation {@link JitterEstimation} */
|
||||
StreamStatistics appStatistics; /**< Stream transmission statistics {@link StreamStatistics} */
|
||||
} info;
|
||||
} QosTv;
|
||||
|
||||
typedef enum {
|
||||
SESSION_OPTION_MAX_SENDBYTES_SIZE = 0, /**< Value type of this option is uint32_t, this option only can be get */
|
||||
SESSION_OPTION_MAX_SENDMESSAGE_SIZE, /**< Value type of this option is uint32_t, this option only can be get */
|
||||
SESSION_OPTION_LINK_TYPE, /**< Value type of this option is int32_t, this option only can be get */
|
||||
|
||||
SESSION_OPTION_BUTT,
|
||||
} SessionOption;
|
||||
|
||||
/**
|
||||
* @brief Defines session callbacks.
|
||||
*
|
||||
* When a session is opened or closed, or there is data to process, the related callback is invoked.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Called when a session is opened.
|
||||
*
|
||||
* This callback is invoked to verify the session or initialize resources related to the session.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param result Indicates the result to return.
|
||||
* @return Returns <b>0</b> if the session is set up; returns a non-zero value
|
||||
* otherwise. You do not need to call {@link CloseSession} to close the session.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int (*OnSessionOpened)(int sessionId, int result);
|
||||
|
||||
/**
|
||||
* @brief Called when a session is closed.
|
||||
*
|
||||
* This callback is invoked to release resources related to the session.
|
||||
* You do not need to call {@link CloseSession}.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnSessionClosed)(int sessionId);
|
||||
|
||||
/**
|
||||
* @brief Called when data is received.
|
||||
*
|
||||
* This callback is invoked to notify that data is received.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param data Indicates the pointer to the data received.
|
||||
* @param dataLen Indicates the length of the data received.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnBytesReceived)(int sessionId, const void *data, unsigned int dataLen);
|
||||
|
||||
/**
|
||||
* @brief Called when a message is received.
|
||||
*
|
||||
* This callback is invoked to notify that a message is received.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param data Indicates the pointer to the message received.
|
||||
* @param dataLen Indicates the length of the message received.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnMessageReceived)(int sessionId, const void *data, unsigned int dataLen);
|
||||
|
||||
/**
|
||||
* @brief Called when stream data is received.
|
||||
*
|
||||
* This callback is invoked to notify that stream data is received.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param data Indicates the pointer to the stream data received.
|
||||
* @param ext Indicates the pointer to the extended service data received.
|
||||
* @param param Indicates the pointer to the stream data frame information.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnStreamReceived)(int sessionId, const StreamData *data, const StreamData *ext,
|
||||
const StreamFrameInfo *param);
|
||||
|
||||
/**
|
||||
* @brief Called when QoS information is retrieved.
|
||||
*
|
||||
* This callback is invoked to notify that QoS information is retrieved.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param eventId Indicates the type of QoS information, such as the channel quality and stream quality.
|
||||
* @param tvCount Indicates the number of TVs returned in the fourth parameter <b>tvList</b>.
|
||||
* @param tvList Indicates the pointer to the TV list.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnQosEvent)(int sessionId, int eventId, int tvCount, const QosTv *tvList);
|
||||
} ISessionListener;
|
||||
|
||||
/**
|
||||
* @brief Defines the callbacks for file receiving.
|
||||
*
|
||||
* The callbacks are invoked to notify the file receiving status.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Called when a file starts to be received.
|
||||
*
|
||||
* This callback is invoked to notify the start of file receiving.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param files Indicates the pointer to the files to receive.
|
||||
* @param fileCnt Indicates the number of files to receive.
|
||||
* @return Returns <b>0</b> if the file receiving starts; returns a non-zero value otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int (*OnReceiveFileStarted)(int sessionId, const char *files, int fileCnt);
|
||||
|
||||
/**
|
||||
* @brief Called when a file is being received.
|
||||
*
|
||||
* This callback is invoked to notify that a file is being received.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param files Indicates the pointer to the first file received.
|
||||
* @param bytesUpload Indicates the size of the files received.
|
||||
* @param bytesTotal Indicates the total size of the files to receive, in bytes.
|
||||
* @return Returns <b>0</b> if a file is being received; returns a non-zero value otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int (*OnReceiveFileProcess)(int sessionId, const char *firstFile, uint64_t bytesUpload, uint64_t bytesTotal);
|
||||
|
||||
/**
|
||||
* @brief Called when the file receiving ends.
|
||||
*
|
||||
* This callback is invoked to notify the end of file receiving.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param files Indicates the pointer to the files received.
|
||||
* @param fileCnt Indicates the number of files received.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnReceiveFileFinished)(int sessionId, const char *files, int fileCnt);
|
||||
|
||||
/**
|
||||
* @brief Called when an error occurs during the file receiving process.
|
||||
*
|
||||
* This callback is invoked to notify a file receiving error.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnFileTransError)(int sessionId);
|
||||
} IFileReceiveListener;
|
||||
|
||||
/**
|
||||
* @brief Defines callbacks for file sending.
|
||||
*
|
||||
* The callbacks are invoked to notify the file sending status.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Called when a file is being sent.
|
||||
*
|
||||
* This callback is invoked to notify that a file is being sent.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param bytesUpload Indicates the size of the file sent, in bytes.
|
||||
* @param bytesTotal Indicates the total size of the file to send, in bytes.
|
||||
* @return Returns <b>0</b> if the file is being sent; returns a non-zero value otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int (*OnSendFileProcess)(int sessionId, uint64_t bytesUpload, uint64_t bytesTotal);
|
||||
|
||||
/**
|
||||
* @brief Called when the file sending ends.
|
||||
*
|
||||
* This callback is invoked to notify the end of file sending.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param firstFile Indicates the pointer to the first file to send.
|
||||
* @return Returns<b>0</b> if the file sending is complete; returns a non-zero value otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int (*OnSendFileFinished)(int sessionId, const char *firstFile);
|
||||
|
||||
/**
|
||||
* @brief Called when an error occurs during the file sending process.
|
||||
*
|
||||
* This callback is invoked to notify a file sending error.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*OnFileTransError)(int sessionId);
|
||||
} IFileSendListener;
|
||||
|
||||
/**
|
||||
* @brief Creates a session server.
|
||||
*
|
||||
* A maximum of 10 session servers can be created.
|
||||
*
|
||||
* @param pkgName Indicates the pointer to the service bundle name.
|
||||
* It is the unique identifier of the upper-layer service. The value cannot be empty or exceed 64 characters.
|
||||
* @param sessionName Indicates the pointer to the session name, which is the unique ID of the session server.
|
||||
* The value cannot be empty or exceed 255 characters.
|
||||
* @param listener Indicates the pointer to the session callback, which cannot be empty.
|
||||
*
|
||||
* @return Returns <b>0</b> if the operation is successful; returns <b>-1</b> otherwise.
|
||||
* @see RemoveSessionServer
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int CreateSessionServer(const char *pkgName, const char *sessionName, const ISessionListener *listener);
|
||||
|
||||
/**
|
||||
* @brief Removes a session server.
|
||||
*
|
||||
* @param pkgName Indicates the pointer to the service bundle name.
|
||||
* It is the unique identifier of the upper-layer service. The value cannot be empty or exceed 64 characters.
|
||||
* @param sessionName Indicates the pointer to the session name. The value cannot be empty or exceed 255 characters.
|
||||
*
|
||||
* @return Returns <b>0</b> if the operation is successful, returns <b>-1</b> otherwise.
|
||||
* @see CreateSessionServer
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int RemoveSessionServer(const char *pkgName, const char *sessionName);
|
||||
|
||||
/**
|
||||
* @brief Opens a session, which is an asynchronous process.
|
||||
*
|
||||
* The session is opened to trigger the first packet interaction process.
|
||||
* {@link OnSessionOpened} is invoked to return whether the session is successfully opened.
|
||||
* Data can be transmitted only after the session is successfully opened.
|
||||
*
|
||||
* @param mySessionName Indicates the pointer to the local session name.
|
||||
* @param peerSessionName Indicates the pointer to the remote session name.
|
||||
* @param peerNetworkId Indicates the pointer to the remote device ID.
|
||||
* @param Indicates the pointer to the group ID. This parameter can be left empty in automatic networking.
|
||||
* In manual networking, you need to apply for a valid group ID from HiChain.
|
||||
* @param attr Indicates the pointer to the session attributes {@link SessionAttribute}.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_TRANS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>INVALID_SESSION_ID</b> if the operation fails.
|
||||
* @return Returns the session ID (an integer greater than <b>0</b>) if the session is opened;
|
||||
* returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int OpenSession(const char *mySessionName, const char *peerSessionName, const char *peerNetworkId,
|
||||
const char *groupId, const SessionAttribute* attr);
|
||||
|
||||
/**
|
||||
* @brief Closes a session.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @return Returns no value.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void CloseSession(int sessionId);
|
||||
|
||||
/**
|
||||
* @example sendbytes_message_demo.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Sends data.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param data Indicates the pointer to the data to send, which cannot be <b>NULL</b>.
|
||||
* @param len Indicates the length of the data to send.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT</b> if the data exceeds the maximum limit.
|
||||
* @return Returns <b>SOFTBUS_TRANS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int SendBytes(int sessionId, const void *data, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Sends a message.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param data Indicates the pointer to the message to send, which cannot be <b>NULL</b>.
|
||||
* @param len Indicates the length of the message to send.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>data</b> is <b>NULL</b> or <b>len</b> is zero.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT</b> if the message length exceeds the limit.
|
||||
* @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int SendMessage(int sessionId, const void *data, unsigned int len);
|
||||
|
||||
/**
|
||||
* @example sendstream_demo.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Sends stream data.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param data Indicates the pointer to the stream data to send, which cannot be <b>NULL</b>.
|
||||
* @param ext Indicates the pointer to the extended stream data to send, which cannot be <b>NULL</b>.
|
||||
* @param param Indicates the pointer to the stream frame information, which cannot be <b>NULL</b>.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if any of the input parameters is <b>NULL</b>.
|
||||
* @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int SendStream(int sessionId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
|
||||
|
||||
/**
|
||||
* @example getsessioninfo_demo.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Obtains the session name registered by the local device.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param sessionName Indicates the pointer to the buffer for storing the session name.
|
||||
* @param len Indicates the length of the buffer.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int GetMySessionName(int sessionId, char *sessionName, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Obtains the session name registered by the peer device.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param sessionName Indicates the pointer to the buffer for storing the session name.
|
||||
* @param len Indicates the length of the buffer.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int GetPeerSessionName(int sessionId, char *sessionName, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Obtains the peer device ID.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param networkId Indicates the pointer to the buffer for storing the device ID.
|
||||
* @param len Indicates the length of the buffer.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int GetPeerDeviceId(int sessionId, char *networkId, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Obtains the session role.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @return Returns <b>-1</b> if the operation fails.
|
||||
* @return Returns <b>0</b> if the session role is a server.
|
||||
* @return Returns <b>1</b> if the session role is a client.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int GetSessionSide(int sessionId);
|
||||
|
||||
/**
|
||||
* @brief Sets a listener for file receiving.
|
||||
*
|
||||
* @param pkgName Indicates the pointer to the registered bundle name, which can be used to check
|
||||
* whether the session server is in this package. The value cannot be empty or exceed 64 characters.
|
||||
* @param sessionName Indicates the pointer to the buffer for storing the session name.
|
||||
* @param recvListener Indicates the pointer to the file receive listener, which cannot be <b>NULL</b>.
|
||||
* @param rootDir Indicates the pointer to the root directory of the file. The length cannot exceed 255 bits.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SESSION_ADDPKG_FAILED</b> if the bundle specified by <b>pkgName</b>
|
||||
* fails to be added.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int SetFileReceiveListener(const char *pkgName, const char *sessionName,
|
||||
const IFileReceiveListener *recvListener, const char *rootDir);
|
||||
|
||||
/**
|
||||
* @brief Sets a listener for file sending.
|
||||
*
|
||||
* @param pkgName Indicates the pointer to the service bundle name.
|
||||
* It is the unique identifier of the upper-layer service. The value cannot be empty or exceed 64 characters.
|
||||
* @param sessionName Indicates the pointer to the buffer for storing the session name.
|
||||
* @param sendListener Indicates the pointer to the file send listener, which cannot be <b>NULL</b>.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SESSION_ADDPKG_FAILED</b> if the bundle specified by <b>pkgName</b>
|
||||
* fails to be added.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int SetFileSendListener(const char *pkgName, const char *sessionName, const IFileSendListener *sendListener);
|
||||
|
||||
/**
|
||||
* @example sendfile_demo.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Sends files.
|
||||
*
|
||||
* @param sessionId Indicates the unique session ID.
|
||||
* @param sFileList Indicates the pointer to the source files to send, which cannot be <b>NULL</b>.
|
||||
* @param dFileList Indicates the pointer to the destination files, which cannot be <b>NULL</b>.
|
||||
* @param fileCnt Indicates the number of files to send, which cannot be <b>0</b>.
|
||||
*
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>sFileList</b> is <b>NULL</b> or <b>fileCnt</b> is <b>0</b>.
|
||||
* @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open.
|
||||
* @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int SendFile(int sessionId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt);
|
||||
|
||||
/**
|
||||
* @brief Get Session based on a session ID.
|
||||
*
|
||||
* @param sessionId Indicates the session ID.
|
||||
* @param option Indicates the session option type to get.
|
||||
* @param optionValue Indicates the session option value to get, which cannot be <b>NULL</b>.
|
||||
* @param valueSize Indicates the size of data which optionValue point to, which cannot be <b>0</b>.
|
||||
* The common error codes are as follows:
|
||||
* @return Returns <b>SOFTBUS_INVALID_PARAM</b> if the option is invalid, optionValue is NULL or valueSize is Zero.
|
||||
* @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if the sessionId is invalid.
|
||||
* @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session current be not enabled.
|
||||
* @return Returns <b>SOFTBUS_OK</b>if the function is called successfully, return other internal errorcodes otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int GetSessionOption(int sessionId, SessionOption option, void* optionValue, uint32_t valueSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // SESSION_H
|
Loading…
Reference in New Issue
Block a user