#include "P2PTunnelCommon.h"
Data Structures | |
struct | st_P2PTunnelSessionInfo |
struct | st_P2PTunnelSessionInfoEx |
Typedefs | |
typedef struct st_P2PTunnelSessionInfo | sP2PTunnelSessionInfo |
typedef struct st_P2PTunnelSessionInfoEx | sP2PTunnelSessionInfoEx |
typedef int32_t(__stdcall * | tunnelSessionInfoCB )(sP2PTunnelSessionInfo *sSessionInfo, void *pArg) |
typedef void(__stdcall * | tunnelSessionInfoExCB )(sP2PTunnelSessionInfoEx *sSessionInfo, const void *pArg) |
typedef int32_t(__stdcall * | tunnelPortVerifyCB )(uint16_t nServicePort, const void *pArg) |
typedef uint16_t(__stdcall * | tunnelServiceVerifyCB )(const char *cszServiceID, const void *pArg) |
typedef void(__stdcall * | tunnelServerAuthCB )(const char *cszAccount, char *cszPassword, uint32_t nPasswordMaxLength, const void *pArg) |
Functions | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnelServerInitialize (uint32_t nMaxAgentConnection) |
Initialize P2PTunnel module in a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelServerInitialize2 (uint32_t nMaxAgentConnection, uint8_t bEnableLanDirect) |
Initialize P2PTunnel module in a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelServerDeInitialize (void) |
Deinitialize P2PTunnel module in a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelServer_Register_Port_Verify (tunnelPortVerifyCB pfxTunnelPortVerifyFn, const void *pArg) |
Register Callback function for verify service port. | |
TUNNEL_API int32_t | P2PTunnelServer_Register_Service_Verify (tunnelServiceVerifyCB pfxTunnelServiceVerifyFn, const void *pArg) |
Register Callback function for verify service id. | |
TUNNEL_API int32_t | P2PTunnelServer_Listen (const int32_t SID, const int32_t CHID) |
Use the existed iotc session to listen incoming P2PTunnel connection. | |
TUNNEL_API int32_t | P2PTunnelServer_Listen_Abort (const int32_t SID, const int32_t CHID) |
Used to gracefully stop P2PTunnelServer_Listen process. | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnelServer_Start (const char *cszUID) |
Start a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelServer_Start_Ex (const char *cszUID, tunnelServerAuthCB pfxTunnelServerAuthFn, tunnelSessionInfoExCB pfxSessionInfoExFn, const void *pArg) |
Start a tunnel server with DTLS mode. | |
TUNNEL_API void | P2PTunnelServer_GetStatus (tunnelStatusCB pfxTunnelStatusFn, void *pArg) |
Used by a tunnel server to get the tunnel status. | |
TUNNEL_API_DEPRECATED int32_t | P2PTunnelServer_GetSessionInfo (tunnelSessionInfoCB pfxSessionInfoFn, void *pArg) |
Used by a tunnel server to get the tunnel session information. | |
TUNNEL_API void | P2PTunnelServer_Stop (void) |
Stop a tunnel server. | |
TUNNEL_API int32_t | P2PTunnelServer_Disconnect (int32_t nSessionID) |
Used by a tunnel server to disconnect a tunnel session. | |
This file describes P2PTunnel module APIs for agent.
typedef struct st_P2PTunnelSessionInfo sP2PTunnelSessionInfo |
P2PTunnel session info, containing all the information when a P2PTunnel session is established between a tunnel server and a tunnel agent. Users can get this information through use P2PTunnelServer_GetSessionInfo() to register a call back function tunnelSessionInfoCB
typedef struct st_P2PTunnelSessionInfoEx sP2PTunnelSessionInfoEx |
P2PTunnel session info, containing all the information when a P2PTunnel session is established between a tunnel server and a tunnel agent. Users can get this information through use P2PTunnelServer_Start_Ex() to register a call back function tunnelSessionInfoExCB
typedef int32_t(__stdcall * tunnelPortVerifyCB)(uint16_t nServicePort, const void *pArg) |
The prototype of Tunnel server verify port of service.
nServicePort | [in] port number that Tunnel agent want to access |
pArg | [in] Tunnel server pass user data |
typedef void(__stdcall * tunnelServerAuthCB)(const char *cszAccount, char *cszPassword, uint32_t nPasswordMaxLength, const void *pArg) |
The prototype of authenticating connect informations, used by a tunnel server to be notified when connection start.
cszAccount | [in] Account from tunnel agent |
cszPassword | [out] The password input by user |
nPasswordMaxLength | [in] Max size of cszPassword |
pArg | [in] Tunnel server pass user data |
typedef uint16_t(__stdcall * tunnelServiceVerifyCB)(const char *cszServiceID, const void *pArg) |
The prototype of Tunnel server to verify Service ID.
cszServiceID | [in] Service ID that Tunnel agent want to access. Max length is MAX_SERVICE_ID_LEN(16). |
pArg | [in] Tunnel server pass user data |
typedef int32_t(__stdcall * tunnelSessionInfoCB)(sP2PTunnelSessionInfo *sSessionInfo, void *pArg) |
The prototype of getting tunnel session information function, used by a tunnel server to be notified after tunnel session is established.
sSessionInfo | [out] About remote session information |
pArg | [out] Tunnel server pass user data |
typedef void(__stdcall * tunnelSessionInfoExCB)(sP2PTunnelSessionInfoEx *sSessionInfo, const void *pArg) |
The prototype of getting tunnel session information function, used by a tunnel server to be notified after tunnel session is established.
sSessionInfo | [out] About remote session information |
pArg | [out] Tunnel server pass user data |
TUNNEL_API int32_t P2PTunnelServer_Disconnect | ( | int32_t | nSessionID | ) |
Used by a tunnel server to disconnect a tunnel session.
This function will disconnect a tunnel session anytime after tunnel session established and it can be called anywhere.
nSessionID | [in] Which session ID of the P2PTunnel session established |
TUNNEL_API_DEPRECATED int32_t P2PTunnelServer_GetSessionInfo | ( | tunnelSessionInfoCB | pfxSessionInfoFn, |
void * | pArg | ||
) |
Used by a tunnel server to get the tunnel session information.
This function will set a callback function pointer in P2PTunnel module for a tunnel server to get the tunnel session information from given callback function. Whenever tunnel agent try to establish session with tunnel server successfully, P2PTunnel module will invoke the given callback function to notify tunnel server and pass information through sP2PTunnelSessionInfo data struct.
pfxSessionInfoFn | [in] The function pointer to get tunnel session information function |
pArg | [in] User can give data pointer to pass to pfxSessionInfoFn when this call back function is triggered. Can be NULL. |
TUNNEL_API void P2PTunnelServer_GetStatus | ( | tunnelStatusCB | pfxTunnelStatusFn, |
void * | pArg | ||
) |
Used by a tunnel server to get the tunnel status.
This function will set a callback function pointer in P2PTunnel module for a tunnel server to get the tunnel status from given callback function. Whenever tunnel status changes, P2PTunnel module will invoke the given callback function to notify tunnel server with corresponding status.
pfxTunnelStatusFn | [in] The function pointer to get 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 P2PTunnelServer_Listen | ( | const int32_t | SID, |
const int32_t | CHID | ||
) |
Use the existed iotc session to listen incoming 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 |
TUNNEL_API int32_t P2PTunnelServer_Listen_Abort | ( | const int32_t | SID, |
const int32_t | CHID | ||
) |
Used to gracefully stop P2PTunnelServer_Listen process.
SID | [in] Base on which IOTC session you want to stop P2PTunnel from listening on |
CHID | [in] Base on which IOTC channel id you want to stop P2PTunnel from listening on |
TUNNEL_API int32_t P2PTunnelServer_Register_Port_Verify | ( | tunnelPortVerifyCB | pfxTunnelPortVerifyFn, |
const void * | pArg | ||
) |
Register Callback function for verify service port.
When Tunnel server recevice request for access service at specific port from remote, SDK will invoke callback function.
pfxTunnelPortVerifyFn | [in] The function pointer to verify service port function. set NULL means allow all port. |
pArg | [in] User can give data pointer to pass to pfxTunnelPortVerifyFn when this callback function is triggered. Can be NULL. |
TUNNEL_API int32_t P2PTunnelServer_Register_Service_Verify | ( | tunnelServiceVerifyCB | pfxTunnelServiceVerifyFn, |
const void * | pArg | ||
) |
Register Callback function for verify service id.
When Tunnel server recevice request for access service at specific service id from remote, SDK will invoke callback function.
pfxTunnelServiceVerifyFn | [in] The function pointer to verify service id function. |
pArg | [in] User can give data pointer to pass to pfxTunnelServiceVerifyFn when this callback function is triggered. Can be NULL. |
TUNNEL_API_DEPRECATED int32_t P2PTunnelServer_Start | ( | const char * | cszUID | ) |
Start a tunnel server.
This function will start a tunnel server with given UID
cszUID | [in] The UID of that tunnel server |
TUNNEL_API int32_t P2PTunnelServer_Start_Ex | ( | const char * | cszUID, |
tunnelServerAuthCB | pfxTunnelServerAuthFn, | ||
tunnelSessionInfoExCB | pfxSessionInfoExFn, | ||
const void * | pArg | ||
) |
Start a tunnel server with DTLS mode.
This function will start a tunnel server with given UID
cszUID | [in] The UID of that tunnel server |
pfxTunnelServerAuthFn | [in] The function pointer of authenticate account function |
pfxSessionInfoExFn | [in] The function pointer to get tunnel session information function. Can be NULL. |
pArg | [in] User can give data pointer to pass to pfxTunnelServerAuthFn and pfxSessionInfoExFn when this call back function is triggered. Can be NULL. |
TUNNEL_API void P2PTunnelServer_Stop | ( | void | ) |
Stop a tunnel server.
This function will stop a tunnel server
TUNNEL_API int32_t P2PTunnelServerDeInitialize | ( | void | ) |
Deinitialize P2PTunnel module in a tunnel server.
This function will deinitialize P2PTunnel module in a tunnel server
TUNNEL_API_DEPRECATED int32_t P2PTunnelServerInitialize | ( | uint32_t | nMaxAgentConnection | ) |
Initialize P2PTunnel module in a tunnel server.
This function is used by a tunnel server to initialize P2PTunnel module and shall be called before any P2PTunnel module related function is invoked.
nMaxAgentConnection | [in] Specify max number of tunnel agents that can connect to this tunnel server |
TUNNEL_API int32_t P2PTunnelServerInitialize2 | ( | uint32_t | nMaxAgentConnection, |
uint8_t | bEnableLanDirect | ||
) |
Initialize P2PTunnel module in a tunnel server.
This function is used by a tunnel server to initialize P2PTunnel module and shall be called before any P2PTunnel module related function is invoked.
nMaxAgentConnection | [in] Specify max number of tunnel agents that can connect to this tunnel server |
bEnableLanDirect | [in] Transport data directly without TUTK forward mechanism when P2PTunnelAgent and P2PTunnelSever are on the same LAN. |