#include "TUTKGlobalAPIs.h"
Typedefs | |
typedef void(__stdcall * | tunnelStatusCB )(int32_t nErrorCode, int32_t nSessionID, void *pArg) |
Enumerations | |
enum | P2PTunnelConnectionType { TUNNEL_CONNECT_AUTO = 0, TUNNEL_CONNECT_MANUAL = 1, TUNNEL_CONNECT_COUNT } |
Functions | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnel_Version (void) |
Get the version of P2PTunnel module. | |
TUNNEL_API const char * | P2PTunnel_Version_String (void) |
Get the version of P2PTunnel module. | |
TUNNEL_API void | P2PTunnelAgent_Set_Log_Path (const char *path, int32_t nMaxSize) |
Set path of log file. | |
TUNNEL_API int32_t | P2PTunnel_Set_Log_Attr (LogAttr logAttr) |
Set Attribute of log file. | |
TUNNEL_API int32_t | P2PTunnelSetConnectionOption (P2PTunnelConnectionType type) |
Setup the connection mode of P2PTunnel. | |
TUNNEL_API int32_t | P2PTunnel_LastIOTime (int32_t nSessionID) |
Get last IO time of SID. | |
TUNNEL_API int32_t | P2PTunnel_SetBufSize (int32_t nSessionID, int32_t nSize) |
Set P2PTunnel buffer size. | |
TUNNEL_API void | P2PTunnel_SetTcpRecvBufSize (uint32_t nSize) |
Set P2PTunnel tcp socket recv buffer size. | |
This file describes common P2PTunnel module APIs of server and agent.
#define MAX_AUTH_DATA_LEN 1000 |
The maximum size, in byte, of the authentication data used in P2PTunnelAgent_Connect()
#define MAX_SERVICE_ID_LEN 32 |
The maximum size, in byte, of Service ID used in P2PTunnelAgent_ServiceMapping()
#define TUNNEL_API __declspec(dllimport) |
#define TUNNEL_API_DEPRECATED |
#define TUNNEL_ER_AGENT_NOT_CONNECTING -30023 |
Tunnel Agent isn't connecting.
#define TUNNEL_ER_AGENT_NOT_SUPPORT -30020 |
Tunnel agent can't call P2PTunnelServer_GetSessionInfo()
#define TUNNEL_ER_ALREADY_CONNECTED -30005 |
Tunnel agent has already connected to a tunnel server, therefore, it failed connect to another tunnel server
#define TUNNEL_ER_ALREADY_INITIALIZED -30007 |
The P2PTunnel module has been initialized in a tunnel server or a tunnel agent
#define TUNNEL_ER_AUTH_FAILED -30008 |
Failed to connect to tunnel server because authentication data is wrong.
#define TUNNEL_ER_BIND_LOCAL_SERVICE -30002 |
Failed to start port mapping when binding because local port had been used by the other service in agent side
#define TUNNEL_ER_CHANNEL_OCCUPIED -30041 |
The specific IOTC session and channel ID is used now so can't use the same resource. You can choose other IOTC channel for RDT use or wait RDT_Abort() to release resource automatically.
#define TUNNEL_ER_CONNECTION_CANCELLED -30025 |
Connection cancelled
#define TUNNEL_ER_CREATE_DTLS_FAIL -30042 |
Fails to create safe channel
#define TUNNEL_ER_DEVICE_NOT_LISTENING -30015 |
Tunner server is not listening for connections.
#define TUNNEL_ER_DEVICE_NOT_ONLINE -30014 |
Tunnel server not login to IOTC server.
#define TUNNEL_ER_DISCONNECTED -30006 |
The tunnel between tunnel agent and tunnel server has been disconnected. Used in tunnel status callback function for notifying tunnel connection status
#define TUNNEL_ER_EXCEED_MAX_LEN -30009 |
Authentication data length exceed MAX_AUTH_DATA_LEN.
#define TUNNEL_ER_EXCEED_MAX_SERVICE -30001 |
The number of P2PTunnel port mapping service has reached maximum. The maximum number of P2PTunnel port mapping service is determined by TUNNEL_MAX_PORT_MAPPING_SERVICE_NUMBER
#define TUNNEL_ER_EXCEED_MAX_SESSION -30019 |
Notify tunnel server session connection alreay reached maximum through tunnelStatusCB, can't be connected anymore until anyone session release.
#define TUNNEL_ER_FAIL_CREATE_THREAD -30004 |
P2PTunnel module fails to create threads. Please check if OS has ability to create threads for P2PTunnel module.
#define TUNNEL_ER_FAILED_SETUP_CONNECTION -30017 |
Tunnel agent failed to connect to tunnel server maybe network unstable.
#define TUNNEL_ER_HANDSHAKE_FAILED -30027 |
P2PTunnel handshake failed.
#define TUNNEL_ER_INIT_OTHER_MODULE_FAIL -30035 |
init other module fail
#define TUNNEL_ER_INVALID_ARG -30021 |
The arguments passed to a function is invalid.
#define TUNNEL_ER_INVALID_RDT_ID -30043 |
The specified RDT channel ID is valid
#define TUNNEL_ER_INVALID_SID -30010 |
The specified P2PTunnel session ID is not valid
#define TUNNEL_ER_LISTEN_LOCAL_SERVICE -30003 |
Failed to start port mapping when listening because local port has been used by the other service in agent side
#define TUNNEL_ER_LOCAL_EXIT -30037 |
Force stop connect proccess by other APIs
#define TUNNEL_ER_LOCAL_NOT_SUPPORT_DTLS -30029 |
Remote P2PTunnel need connect with DTLS
#define TUNNEL_ER_LOGIN_FAILED -30018 |
Tunnel server failed to login to IOTC Server but still can be connected by tunnel agent on LAN.
#define TUNNEL_ER_NETWORK_UNREACHABLE -30016 |
Internet not available or firewall block.
#define TUNNEL_ER_NO_FREE_SESSION -30024 |
Unable to get free session.
#define TUNNEL_ER_NoERROR 0 |
The function is performed successfully.
#define TUNNEL_ER_NOT_INITIALIZED -30000 |
P2PTunnel module is not initialized yet. Please use P2PTunnelServerInitialize() or P2PTunnelAgentInitialize() for initialization.
#define TUNNEL_ER_OPERATION_IS_INVALID -30026 |
The API operation is invalid
#define TUNNEL_ER_OS_RESOURCE_LACK -30022 |
OS resource not enough to malloc memory or open socket.
#define TUNNEL_ER_RDT_DESTROYED -30044 |
RDT channel has been destroyed. Probably caused by local or remote site calls RDT_Destroy(), or remote site has closed IOTC session.
#define TUNNEL_ER_RDT_EXCEED_MAX_CHANNEL -30040 |
The number of RDT channels has reached maximum. Please use RDT_Set_Max_Channel_Number() to set up the max number of RDT channels. By default, the maximum channel number is MAX_DEFAULT_RDT_CHANNEL_NUMBER.
#define TUNNEL_ER_RDT_RCV_DATA_END -30045 |
The remote site has finished sending data, then destroy the RDT channel. The local site will get this error code by RDT_Read() when there is no more data from this RDT channel.
#define TUNNEL_ER_REJECT -30033 |
API or remote reject
#define TUNNEL_ER_REMOTE_NOT_SUPPORT -30036 |
Remote P2PTunnel not support this feature
#define TUNNEL_ER_REMOTE_NOT_SUPPORT_DTLS -30028 |
Remote P2PTunnel not support DTLS
#define TUNNEL_ER_REMOTE_RDT_ABORT -30039 |
The remote site want to abort the RDT channel immediately and don't care data transmission. The local site will get this error code by RDT_Read(), RDT_Write(), RDT_Destroy() for handling this RDT channel to close.
#define TUNNEL_ER_REMOTE_RDT_EXIT -30038 |
The remote site called RDT_Create_Exit() so the RDT channel exit creating.
#define TUNNEL_ER_REMOTE_TIMEOUT_DISCONNECT -30032 |
This IOTC session is disconnected because remote site has no any response after a specified timeout expires.
#define TUNNEL_ER_RETRY -30034 |
retry API
#define TUNNEL_ER_SESSION_CLOSE_BY_REMOTE -30031 |
The remote site already closes the IOTC session. Please call IOTC_Session_Close() to release local IOTC session resource
#define TUNNEL_ER_TIMEOUT -30030 |
API timeout
#define TUNNEL_ER_UID_NO_PERMISSION -30012 |
The specified device does not support advance function (TCP relay and P2PTunnel module)
#define TUNNEL_ER_UID_NOT_SUPPORT_RELAY -30013 |
This UID can't setup connection through relay.
#define TUNNEL_ER_UID_UNLICENSE -30011 |
This UID is illegal.
#define TUNNEL_ER_UNDEFINED -31000 |
#define TUNNEL_MAX_PORT_MAPPING_SERVICE_NUMBER 256 |
The maximum number of port mapping service in P2PTunnel module
typedef void(__stdcall * tunnelStatusCB)(int32_t nErrorCode, int32_t nSessionID, void *pArg) |
The prototype of getting tunnel status function, used by a tunnel server or tunnel agent to be notified if tunnel status is changed.
nErrorCode | [out]
|
nSessionID | [in] Which session ID of the P2PTunnel session disconnected |
pArg | [out] Tunnel server or agent pass user data |
TUNNEL_API int32_t P2PTunnel_LastIOTime | ( | int32_t | nSessionID | ) |
Get last IO time of SID.
Get last IO time of SID even if the connection is closed.
nSessionID | [in] Session ID |
TUNNEL_API int32_t P2PTunnel_Set_Log_Attr | ( | LogAttr | logAttr | ) |
Set Attribute of log file.
logAttr | [in] See LogAttr |
TUNNEL_API int32_t P2PTunnel_SetBufSize | ( | int32_t | nSessionID, |
int32_t | nSize | ||
) |
Set P2PTunnel buffer size.
Set P2PTunnel buffer size, larger buffer leads more maximum throughput
nSessionID | [in] Session ID |
nSize | [in] Buffer size in Bytes |
TUNNEL_API void P2PTunnel_SetTcpRecvBufSize | ( | uint32_t | nSize | ) |
Set P2PTunnel tcp socket recv buffer size.
Set P2PTunnel tcp socket recv buffer size, larger buffer leads more maximum throughput
nSize | [in] Buffer size in Bytes |
TUNNEL_API_DEPRECATED int32_t P2PTunnel_Version | ( | void | ) |
Get the version of P2PTunnel module.
This function returns the version of P2PTunnel module.
TUNNEL_API const char* P2PTunnel_Version_String | ( | void | ) |
Get the version of P2PTunnel module.
This function returns the version of P2PTunnel module.
TUNNEL_API void P2PTunnelAgent_Set_Log_Path | ( | const char * | path, |
int32_t | nMaxSize | ||
) |
Set path of log file.
Set the absolute path of log file
path | [in] The path of log file, NULL = disable Log |
nMaxSize | [in] The maximum size of log file in Bytes, 0 = unlimit |
TUNNEL_API int32_t P2PTunnelSetConnectionOption | ( | P2PTunnelConnectionType | type | ) |
Setup the connection mode of P2PTunnel.
Use TUNNEL_CONNECT_MANUAL mode if you need share IOTC session with other modules, like AV or RDT. Otherwize there is no need to call this API.