#include "P2PTunnelCommon.h"
Typedefs | |
typedef void(__stdcall * | tunnelAgentAuthCB )(char *cszAccount, uint32_t nAccountMaxLength, char *cszPassword, uint32_t nPasswordMaxLength, const void *pArg) |
Functions | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnelAgentInitialize (uint32_t nMaxConnection) |
Initialize P2PTunnel module in a tunnel agent. | |
TUNNEL_API int32_t | P2PTunnelAgentInitialize2 (uint32_t nMaxConnection, uint8_t bEnableLanDirect) |
Initialize P2PTunnel module in a tunnel agent. | |
TUNNEL_API int32_t | P2PTunnelAgentDeInitialize (void) |
Deinitialize P2PTunnel module in a tunnel agent. | |
TUNNEL_API int32_t | P2PTunnelAgent_GetFreeSession (void) |
Used by an agent to get a free session ID. | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnelAgent_Connect (const char *cszUID, const void *cpAuthData, int32_t nAuthDataLength, int32_t *pnErrFromDeviceCB) |
Connect to a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelAgent_Connect_Ex (const char *cszUID, tunnelAgentAuthCB pfxTunnelAgentAuthFn, const void *pArg) |
Connect to a tunnel server with DTLS mode. | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnelAgent_Attach_Connect (const int32_t SID, const int32_t CHID, const void *cpAuthData, int32_t nAuthDataLength, int32_t *pnErrFromDeviceCB) |
Use the existed IOTC session to request P2PTunnel connection. | |
TUNNEL_API int32_t | P2PTunnelAgent_Attach_Connect_Ex (int32_t SID, int32_t CHID, tunnelAgentAuthCB pfxTunnelAgentAuthFn, const void *pArg) |
Use the existed IOTC session to request P2PTunnel connection with DTLS mode. | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnelAgent_Connect_Parallel (const char *cszUID, const int32_t SID, const void *cpAuthData, int32_t nAuthDataLength, int32_t *pnErrFromDeviceCB) |
Connect to a tunnel server and bind to a specified session ID. | |
TUNNEL_API int32_t | P2PTunnelAgent_Connect_Parallel_Ex (const char *cszUID, int32_t SID, tunnelAgentAuthCB pfxTunnelAgentAuthFn, const void *pArg) |
Connect to a tunnel server and bind to a specified session ID with DTLS mode. | |
TUNNEL_API int32_t | P2PTunnelAgent_Disconnect (int32_t nSessionID) |
Disconnect to a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelAgent_Abort (int32_t nSessionID) |
Abort the connection with a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelAgent_PortMapping (int32_t nSessionID, uint16_t nLocalPort, uint16_t nRemotePort) |
Start port mapping service. | |
TUNNEL_API int32_t | P2PTunnelAgent_ServiceMapping (int32_t nSessionID, uint16_t nLocalPort, const char *cszServiceID) |
Start connection for bacchus service. | |
TUNNEL_API void | P2PTunnelAgent_StopPortMapping (uint32_t nPortMappingIdx) |
Stop port mapping service. | |
TUNNEL_API void | P2PTunnelAgent_StopServiceMapping (uint32_t nServiceMappingIdx) |
Stop service. | |
TUNNEL_API int32_t | P2PTunnelAgent_StopPortMapping_byIndexArray (uint32_t *indexArray, uint32_t indexNum) |
Stop port mapping service. | |
TUNNEL_API void | P2PTunnelAgent_GetStatus (tunnelStatusCB pfxTunnelStatusFn, void *pArg) |
Used by a tunnel agent to get the tunnel status. | |
TUNNEL_API int32_t | P2PTunnelAgent_Connect_Stop (const char *cszUID) |
It's to stop the progressing of connection. | |
TUNNEL_API int32_t | P2PTunnelAgent_Connect_Stop_Parallel (const char *cszUID, const int32_t nSessionID) |
It's to stop the progressing of connection. | |
TUNNEL_API int32_t | P2PTunnelAgent_Attach_Connect_Stop (int32_t nIOTCSessionID, int32_t nIOTCChannelID) |
It's to stop the progressing of attach. | |
This file describes P2PTunnel module APIs for agent.
typedef void(__stdcall * tunnelAgentAuthCB)(char *cszAccount, uint32_t nAccountMaxLength, char *cszPassword, uint32_t nPasswordMaxLength, const void *pArg) |
The prototype of authenticating connect informations, used by a tunnel agent to be notified when connection start.
cszAccount | [out] The account input by user |
nAccountMaxLength | [in] Max size of cszAccount |
cszPassword | [out] The password input by user |
nPasswordMaxLength | [in] Max size of cszPassword |
pArg | [in] Tunnel agent pass user data |
TUNNEL_API int32_t P2PTunnelAgent_Abort | ( | int32_t | nSessionID | ) |
Abort the connection with a tunnel server.
This function used by a tunnel agent to disconnect to a tunnel server directly
nSessionID | [in] Which session ID of the P2PTunnel session to be disconnect |
TUNNEL_API_DEPRECATED int32_t P2PTunnelAgent_Attach_Connect | ( | const int32_t | SID, |
const int32_t | CHID, | ||
const void * | cpAuthData, | ||
int32_t | nAuthDataLength, | ||
int32_t * | pnErrFromDeviceCB | ||
) |
Use the existed IOTC session to request P2PTunnel connection.
In order to use the same iotc session with other modules, please make sure you use different channel id for each module, for example, you can use channel 0 for AV connections and channel 1 for P2PTunnel connections
SID | [in] Base on which IOTC session id you want to build P2PTunnel connection |
CHID | [in] Base on which IOTC channel id you want to build P2PTunnel connection |
cpAuthData | [in] Send authentication data to tunnel server for connection. |
nAuthDataLength | [in] The length of the byte buffer. It cannot be larger than MAX_AUTH_DATA_LEN |
pnErrFromDeviceCB | [out] The reason why tunnel server rejects this connection. It's returned from tunnelSessionInfoCB of the tunnel server. |
TUNNEL_API int32_t P2PTunnelAgent_Attach_Connect_Ex | ( | int32_t | SID, |
int32_t | CHID, | ||
tunnelAgentAuthCB | pfxTunnelAgentAuthFn, | ||
const void * | pArg | ||
) |
Use the existed IOTC session to request P2PTunnel connection with DTLS mode.
In order to use the same iotc session with other modules, please make sure you use different channel id for each module, for example, you can use channel 0 for AV connections and channel 1 for P2PTunnel connections
SID | [in] Base on which IOTC session id you want to build P2PTunnel connection |
CHID | [in] Base on which IOTC channel id you want to build P2PTunnel connection |
pfxTunnelAgentAuthFn | [in] The function pointer of authenticate account function if IOTC session is crate by Nebula, this param can be NULL. |
pArg | [in] User can give data pointer to pass to pfxTunnelAgentAuthFn when this call back function is triggered. Can be NULL. |
TUNNEL_API int32_t P2PTunnelAgent_Attach_Connect_Stop | ( | int32_t | nIOTCSessionID, |
int32_t | nIOTCChannelID | ||
) |
It's to stop the progressing of attach.
This API is for a manually agnet to stop connecting to a device. We can use it to stop connecting when client blocks in P2PTunnelAgent_Attach_Connect() or P2PTunnelAgent_Attach_Connect_Ex().
nIOTCSessionID | [in] Session ID |
nIOTCChannelID | [in] Channel ID |
TUNNEL_API_DEPRECATED int32_t P2PTunnelAgent_Connect | ( | const char * | cszUID, |
const void * | cpAuthData, | ||
int32_t | nAuthDataLength, | ||
int32_t * | pnErrFromDeviceCB | ||
) |
Connect to a tunnel server.
This function used by a tunnel agent to connect the tunnel server with specified UID
cszUID | [in] The UID of that tunnel server to be connected |
cpAuthData | [in] Send authentication data to tunnel server for connection. |
nAuthDataLength | [in] The length of the byte buffer. It cannot be larger than MAX_AUTH_DATA_LEN |
pnErrFromDeviceCB | [out] The reason why tunnel server rejects this connection. It's returned from tunnelSessionInfoCB of the tunnel server. |
TUNNEL_API int32_t P2PTunnelAgent_Connect_Ex | ( | const char * | cszUID, |
tunnelAgentAuthCB | pfxTunnelAgentAuthFn, | ||
const void * | pArg | ||
) |
Connect to a tunnel server with DTLS mode.
This function used by a tunnel agent to connect the tunnel server with specified UID
cszUID | [in] The UID of that tunnel server to be connected |
pfxTunnelAgentAuthFn | [in] The function pointer of authenticate account function |
pArg | [in] User can give data pointer to pass to pfxTunnelAgentAuthFn when this call back function is triggered. Can be NULL. |
TUNNEL_API_DEPRECATED int32_t P2PTunnelAgent_Connect_Parallel | ( | const char * | cszUID, |
const int32_t | SID, | ||
const void * | cpAuthData, | ||
int32_t | nAuthDataLength, | ||
int32_t * | pnErrFromDeviceCB | ||
) |
Connect to a tunnel server and bind to a specified session ID.
This function is for a tunnel agent to connect a device by specifying the UID of that device, and bind to a free session ID from P2PTunnelAgent_GetFreeSession(). If connection is established with the help of IOTC servers, the TUNNEL_ER_NoERROR will be returned in this function and then device and client can communicate for the other later by using this tunnel session ID. If this function is called by multiple threads, the connections will be processed concurrently.
cszUID | [in] The UID of that tunnel server to be connected |
SID | [in] The SID got from P2PTunnelAgent_GetFreeSession() the connection should bind to. |
cpAuthData | [in] Send authentication data to tunnel server for connection. |
nAuthDataLength | [in] The length of the byte buffer. It cannot be larger than MAX_AUTH_DATA_LEN |
pnErrFromDeviceCB | [out] The reason why tunnel server rejects this connection. It's returned from tunnelSessionInfoCB of the tunnel server. |
TUNNEL_API int32_t P2PTunnelAgent_Connect_Parallel_Ex | ( | const char * | cszUID, |
int32_t | SID, | ||
tunnelAgentAuthCB | pfxTunnelAgentAuthFn, | ||
const void * | pArg | ||
) |
Connect to a tunnel server and bind to a specified session ID with DTLS mode.
This function is for a tunnel agent to connect a device by specifying the UID of that device, and bind to a free session ID from P2PTunnelAgent_GetFreeSession(). If connection is established with the help of IOTC servers, the TUNNEL_ER_NoERROR will be returned in this function and then device and client can communicate for the other later by using this tunnel session ID. If this function is called by multiple threads, the connections will be processed concurrently.
cszUID | [in] The UID of that tunnel server to be connected |
SID | [in] The SID got from P2PTunnelAgent_GetFreeSession() the connection should bind to. |
pfxTunnelAgentAuthFn | [in] The function pointer of authenticate account function if IOTC session is crate by Nebula, this param can be NULL. |
pArg | [in] User can give data pointer to pass to pfxTunnelAgentAuthFn when this call back function is triggered. Can be NULL. |
TUNNEL_API int32_t P2PTunnelAgent_Connect_Stop | ( | const char * | cszUID | ) |
It's to stop the progressing of connection.
This API is for a client to stop connecting to a device. We can use it to stop connecting when client blocks in P2PTunnelAgent_Connect_Ex().
cszUID | [in] The UID of that tunnel server |
TUNNEL_API int32_t P2PTunnelAgent_Connect_Stop_Parallel | ( | const char * | cszUID, |
const int32_t | nSessionID | ||
) |
It's to stop the progressing of connection.
This API is for a client to stop connecting to a device. We can use it to stop connecting when client blocks in P2PTunnelAgent_Connect_Parallel_Ex().
cszUID | [in] The UID of that tunnel server |
nSessionID | [in] Session ID |
TUNNEL_API int32_t P2PTunnelAgent_Disconnect | ( | int32_t | nSessionID | ) |
Disconnect to a tunnel server.
This function used by a tunnel agent to disconnect to a tunnel server gracefully
nSessionID | [in] Which session ID of the P2PTunnel session to be disconnect |
TUNNEL_API int32_t P2PTunnelAgent_GetFreeSession | ( | void | ) |
Used by an agent to get a free session ID.
This function is for an agent to get a free session ID used for a parameter of P2PTunnelAgent_Connect_Parallel_Ex().
TUNNEL_API void P2PTunnelAgent_GetStatus | ( | tunnelStatusCB | pfxTunnelStatusFn, |
void * | pArg | ||
) |
Used by a tunnel agent to get the tunnel status.
This function will set a callback function pointer in P2PTunnel module for a tunnel agent to get the tunnel status from given callback function. Whenever tunnel status changes, P2PTunnel module will invoke the given callback function to notify tunnel agent with corresponding status.
pfxTunnelStatusFn | [in] The function pointer to getting tunnel status function |
pArg | [in] User can give data pointer to pass to pfxSessionInfoFn when this call back function is triggered. Can be NULL. |
TUNNEL_API int32_t P2PTunnelAgent_PortMapping | ( | int32_t | nSessionID, |
uint16_t | nLocalPort, | ||
uint16_t | nRemotePort | ||
) |
Start port mapping service.
This function used by a tunnel agent to start port mapping service provided by P2PTunnel module. The tunnel agent specifies the local port in local host through which a tunnel is created with the remote port defined in the tunnel server.
nSessionID | [in] Which session ID of the P2PTunnel session to process the port mapping service |
nLocalPort | [in] The local port used to create a tunnel with the tunnel server |
nRemotePort | [in] The remote port defined in the tunnel server to create a tunnel |
TUNNEL_API int32_t P2PTunnelAgent_ServiceMapping | ( | int32_t | nSessionID, |
uint16_t | nLocalPort, | ||
const char * | cszServiceID | ||
) |
Start connection for bacchus service.
This function used by a tunnel agent to start connection for a bacchus service provided by P2PTunnel module. The tunnel agent specifies the local port in local host through which a tunnel is created with the service id defined in the tunnel server.
nSessionID | [in] Which session ID of the P2PTunnel session to process the port mapping service |
nLocalPort | [in] The local port used to create a tunnel with the tunnel server |
cszServiceID | [in] The remote service id defined in the tunnel server to create a tunnel. Max length is MAX_SERVICE_ID_LEN(16). |
TUNNEL_API void P2PTunnelAgent_StopPortMapping | ( | uint32_t | nPortMappingIdx | ) |
Stop port mapping service.
This function used by a tunnel agent to stop port mapping service on a given port mapping index which is started by P2PTunnelAgent_PortMapping()
nPortMappingIdx | [in] The port mapping index started in P2PTunnelAgent_PortMapping() |
TUNNEL_API int32_t P2PTunnelAgent_StopPortMapping_byIndexArray | ( | uint32_t * | indexArray, |
uint32_t | indexNum | ||
) |
Stop port mapping service.
This function used by a tunnel agent to stop multiple port mapping service on an integer array set of given port mapping index which is started by P2PTunnelAgent_PortMapping()
indexArray | [in] An integer array of the port mapping index in P2PTunnelAgent_PortMapping() |
indexNum | [in] The number of the port mapping index in indexArray |
TUNNEL_API void P2PTunnelAgent_StopServiceMapping | ( | uint32_t | nServiceMappingIdx | ) |
Stop service.
This function used by a tunnel agent to stop service on a given port mapping index which is started by P2PTunnelAgent_ServiceMapping()
nServiceMappingIdx | [in] The port mapping index started in P2PTunnelAgent_ServiceMapping() |
TUNNEL_API int32_t P2PTunnelAgentDeInitialize | ( | void | ) |
Deinitialize P2PTunnel module in a tunnel agent.
This function will deinitialize P2PTunnel module in a tunnel agent
TUNNEL_API_DEPRECATED int32_t P2PTunnelAgentInitialize | ( | uint32_t | nMaxConnection | ) |
Initialize P2PTunnel module in a tunnel agent.
This function is used by a tunnel agent to initialize P2PTunnel module and shall be called before any P2PTunnel module related function is invoked.
nMaxConnection | [in] Specify max number of tunnel agents that can connect to tunnel servers |
TUNNEL_API int32_t P2PTunnelAgentInitialize2 | ( | uint32_t | nMaxConnection, |
uint8_t | bEnableLanDirect | ||
) |
Initialize P2PTunnel module in a tunnel agent.
This function is used by a tunnel agent to initialize P2PTunnel module and shall be called before any P2PTunnel module related function is invoked.
nMaxConnection | [in] Specify max number of tunnel agents that can connect to tunnel servers |
bEnableLanDirect | [in] Transport data directly without TUTK forward mechanism when P2PTunnelAgent and P2PTunnelSever are on the same LAN. |