NetTunnelWindows/NetTunnelSDK/include/sccsdk.h

303 lines
11 KiB
C
Raw Normal View History

#pragma once
#include <Windows.h>
#include "common.h"
#include "usrerr.h"
#ifdef NETTUNNELSDK_EXPORTS
#define SCCSDK_API __declspec(dllexport)
#else
#define SCCSDK_API __declspec(dllimport)
#endif
typedef void (*PTUNNEL_HEART_ROUTINE)(const TCHAR *pMessage, unsigned int timeStampOfSeconds);
typedef PTUNNEL_HEART_ROUTINE LPTUNNEL_HEART_ROUTINE;
/**
*
* @brief
*/
typedef struct {
int InterfaceIndex; ///< 网卡索引
NET_CONNECT_STATUS netConnStatus; ///< 网卡状态 @see NET_CONNECT_STATUS
TCHAR NetCardUUID[260]; ///< 网卡名称, Windows标识为 UUID
TCHAR NetCardName[MAX_NETCARD_NAME]; ///< 网卡名称
TCHAR NetCardDescription[132]; ///< 网卡描述
TCHAR NetCardIpaddr[MAX_IP_LEN]; ///< 网卡 IP 地址
TCHAR NetCardNetmask[MAX_IP_LEN]; ///< 网卡子网掩码
TCHAR NetCardGateway[MAX_IP_LEN]; ///< 网卡网关
TCHAR NetCardMacAddr[20]; ///< 网卡 MAC 地址
} NIC_CONTENT, *PNIC_CONTENT;
#ifdef __cplusplus // If used by C++ code,
extern "C" {
// we need to export the C interface
#endif
/**
* @brief SDK
* @param[in] pWorkDir
* @param[in] pSvrUrl URL example: http://localhost:2313, https://localhost:2313
* @param[in] pLogFile /
* @param[in] level
* @param[in] isWorkServer SDK
* - TRUE
* - FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_ITEM_EXISTS WireGuard
* - -ERR_SYS_CALL
* - -ERR_CREATE_FILE
* - -ERR_ITEM_UNEXISTS WireGuard
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl TunnelSDKInitEnv(const TCHAR *pWorkDir,
const TCHAR *pSvrUrl,
const TCHAR *pLogFile,
LOG_LEVEL level,
bool isWorkServer);
/**
* @brief SDK
*/
SCCSDK_API void __cdecl TunnelSDKUnInit();
/**
* @brief / SDK
* @param enLog
* - TRUE
* - FALSE
*/
SCCSDK_API void __cdecl TunnelLogEnable(bool enLog);
/**
* @brief WireGuard
* @param pTunnelName
* @param pIsRunning pIsRunning WireGuard
* - TRUE
* - FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_OPEN_SCM
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl GetWireGuardServiceStatus(const TCHAR *pTunnelName, bool *pIsRunning);
/**
* @brief /
* @param[out] pIsWorkServer
* - TRUE
* - FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl GetWireGuardWorkMode(bool *pIsWorkServer);
/**
* @brief WireGuard
* @param[in] pIfName WireGuard
* @param[out] pIsRunning WireGuard
* - TRUE
* - FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl IsWireGuardServerRunning(const TCHAR *pIfName, bool *pIsRunning);
/**
* @brief SCG
* @param isEnable TRUE: SCG , FALSE: SCG
* @param pSCGIpAddr SCG IP
* @param scgPort SCG
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl EnableSCGProxy(bool isEnable, const TCHAR *pSCGIpAddr, int scgPort);
/**
* @brief SCG
* @return TRUE: SCG , FALSE: SCG
*/
SCCSDK_API bool __cdecl UsedSCGProxy();
/**
* @brief
* @return @see NET_SHARE_MODE
*/
SCCSDK_API NET_SHARE_MODE __cdecl GetCurrentNetShareMode();
/**
* @brief
* @param shareMode @see NET_SHARE_MODE
*/
SCCSDK_API void __cdecl SetCurrentNetShareMode(NET_SHARE_MODE shareMode);
/**
* @brief
* @param[out] pInfo @see NIC_CONTENT
* @param[out] pItemCounts 32
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl GetAllNICInfo(PNIC_CONTENT *pInfo, int *pItemCounts);
/**
* @brief Internet
* @param[out] pIfIndex
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_ITEM_UNEXISTS Internet
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl GetInternetIfIndex(int *pIfIndex);
/**
* @brief Internet
* @param[in] ifIndex
* @param[in] pRet
* - TRUE Internet
* - FALSE Internet
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_GET_IPFOWARDTBL
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl IsInternetConnectAdapter(int ifIndex, bool *pRet);
/**
* @brief
* @param pClientId ID
* @param pClientSecret
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl EnableVerifySignature(const TCHAR *pClientId, const TCHAR *pClientSecret);
/**
* @brief
*/
SCCSDK_API void __cdecl DisableVerifySignature();
/**
* @brief
* @param pSvr
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_CREATE_THREAD 线
* - -ERR_SOCKET_BIND_PORT
* - -ERR_ITEM_EXISTS 线
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl CreateControlService(PUSER_SERVER_CONFIG pSvr);
/**
* @brief
* @param[in] pUserName
* @param[in] pToken 访
* @param[out] pSvrCfg
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CREATE_FILE
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl GetUserServerConfigure(const TCHAR *pUserName,
const TCHAR *pToken,
PUSER_SERVER_CONFIG *pSvrCfg);
/**
* @brief
* @param[in] pUserName
* @param[in] pToken 访
* @param[out] pCliCfg
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CREATE_FILE
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl GetUserClientConfigure(const TCHAR *pUserName,
const TCHAR *pToken,
PUSER_CLIENT_CONFIG *pCliCfg);
/**
* @brief
* @return 0: 0 @see USER_ERRNO
* - -ERROR_TIMEOUT
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl StopControlService();
/**
* @brief
* @param[in] vmId ID编号
* @param[in] pCliNetwork
* @return 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_SYSTEM_UNINITIALIZE
* - -ERR_MALLOC_MEMORY
* - -ERR_OPEN_FILE
* - -ERR_MEMORY_STR
* - -ERR_UN_SUPPORT
* - -ERR_JSON_CREATE JSON
* - -ERR_HTTP_POST_DATA POST
* - -ERR_HTTP_SERVER_RSP 200
* - -ERR_READ_FILE
* - -ERR_JSON_DECODE JSON
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl RemoteCtrlSvrCfgUserTunnel(int vmId, const TCHAR *pCliNetwork);
/**
* @brief / WireGuard
* @param[in] isStart / TRUE , FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_SYSTEM_UNINITIALIZE URL
* - -ERR_CREATE_FILE
* - -ERR_HTTP_POST_DATA POST
* - -ERR_HTTP_SERVER_RSP HTTP
* - -ERR_READ_FILE
* - -ERR_JSON_DECODE JSON
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl RemoteWireGuardControl(bool isStart);
/**
* @brief / WireGuard
* @param[in] isStart / TRUE , FALSE
* @param[in] setPrivateMode (Private)
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_NET_CATEGORY_MODE
* - -ERR_UN_SUPPORT
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl LocalWireGuardControl(bool isStart, bool setPrivateMode);
/**
* @brief /
* @param isStart / TRUE , FALSE
* @param lpHeartCbAddress @see PTUNNEL_HEART_ROUTINE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_CREATE_TIMER
* - -ERR_DELETE_TIMER
* - ERR_SUCCESS
*/
SCCSDK_API int __cdecl RemoteHeartControl(bool isStart, LPTUNNEL_HEART_ROUTINE lpHeartCbAddress);
/**
* @brief
* @param err
* @return , "UNKNOWN":
*/
SCCSDK_API const CHAR* __cdecl GetSDKErrorMessage(USER_ERRNO err);
#ifdef __cplusplus
}
#endif