NetTunnelWindows/NetTunnelSDK/include/user.h

168 lines
6.6 KiB
C
Raw Normal View History

#pragma once
#include <Windows.h>
#ifdef NETTUNNELSDK_EXPORTS
#define USERMANAGER_API __declspec(dllexport)
#else
#define USERMANAGER_API __declspec(dllimport)
#endif
#define HEART_PERIOD_MS (3000)
typedef void (*PTUNNEL_HEART_ROUTINE)(const TCHAR *pMessage, unsigned int timeStampOfSeconds);
typedef PTUNNEL_HEART_ROUTINE LPTUNNEL_HEART_ROUTINE;
/**
*
* @brief
*/
typedef struct {
int isCurrent; ///< 网卡 MAC 地址
TCHAR CfgPath[260]; ///< 配置文件路径
} USER_CFGFILE, *PUSER_CFGFILE;
#ifdef __cplusplus // If used by C++ code,
extern "C" {
// we need to export the C interface
#endif
/**
* @brief
* @param pUserSvrUrl URL
*/
USERMANAGER_API void __cdecl ConnectServerControlService(const TCHAR *pUserSvrUrl);
/**
* @brief
* @param pSvr
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_CREATE_THREAD 线
* - -ERR_SOCKET_BIND_PORT
* - -ERR_ITEM_EXISTS 线
* - ERR_SUCCESS
*/
USERMANAGER_API int __cdecl CreateControlService(PUSER_SERVER_CONFIG pSvr);
/**
* @brief
* @return 0: 0 @see USER_ERRNO
* - -ERROR_TIMEOUT
* - ERR_SUCCESS
*/
USERMANAGER_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
*/
USERMANAGER_API int __cdecl RemoteCtrlSvrCfgUserTunnel(int vmId, const TCHAR *pCliNetwork);
/**
* @brief WireGuard
* @param[in] pCliPrivateKey
* @param[in] pSvrPublicKey
* @param[in] pSvrNetwork 访
* @param[in] pCliNetwork
* @param[in] pSvrTunnelAddr
* @param[in] pSvrEndPoint
* @return 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_SYSTEM_UNINITIALIZE
* - -ERR_MALLOC_MEMORY
* - -ERR_OPEN_FILE
* - -ERR_MEMORY_STR
* - -ERR_UN_SUPPORT
* - -ERR_MALLOC_MEMORY
* - ERR_SUCCESS
*/
USERMANAGER_API int __cdecl SetTunnelConfigure(const TCHAR *pCliPrivateKey,
const TCHAR *pSvrPublicKey,
const TCHAR *pSvrNetwork,
const TCHAR *pCliNetwork,
const TCHAR *pSvrTunnelAddr,
const TCHAR *pSvrEndPoint);
/**
* @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
*/
USERMANAGER_API int __cdecl RemoteHeartControl(bool isStart, LPTUNNEL_HEART_ROUTINE lpHeartCbAddress);
/**
* @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
*/
USERMANAGER_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
*/
USERMANAGER_API int __cdecl LocalWireGuardControl(bool isStart, bool setPrivateMode);
/**
* @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
*/
USERMANAGER_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
*/
USERMANAGER_API int __cdecl GetUserClientConfigure(const TCHAR *pUserName,
const TCHAR *pToken,
PUSER_CLIENT_CONFIG *pCliCfg);
USERMANAGER_API int __cdecl GetUserConfigFiles(const TCHAR *pUserName, PUSER_CFGFILE* pCfgFile, int *pItems);
#ifdef __cplusplus
}
#endif