NetTunnelWindows/NetTunnelSDK/include/network.h

344 lines
12 KiB
C
Raw Normal View History

#pragma once
#include "sccsdk.h"
#ifdef __cplusplus // If used by C++ code,
extern "C" {
// we need to export the C interface
#endif
/**
* @brief IP地址
* @param[in] pIpAddr IP地址
* @param[out] pIfIndex
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - -ERR_ITEM_UNEXISTS
* - -ERR_UN_SUPPORT
* - ERR_SUCCESS
*/
int GetInterfaceIfIndexByIpAddr(const TCHAR *pIpAddr, ULONG *pIfIndex);
/**
* @brief GUDI
* @param[in] pGUID GUID
* @param[out] ifName
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - -ERR_CREATE_COMMOBJECT COM
* - -ERR_SYS_CALL COM
* - -ERR_ITEM_UNEXISTS GUID
* - ERR_SUCCESS
*/
int GetInterfaceNameByGUID(const TCHAR *pGUID, TCHAR ifName[MAX_NETCARD_NAME]);
/**
* @brief
* @param[in] pInterfaceName
* @param[out] pIfIndex Index
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_ITEM_UNEXISTS
* - -ERR_SYS_CALL
* - -ERR_MALLOC_MEMORY
* - ERR_SUCCESS
*/
int GetInterfaceIfIndexByName(const TCHAR *pInterfaceName, int *pIfIndex);
/**
* @brief GUID
* @param[in] ifIndex
* @param[out] pGuid GUID
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_ITEM_UNEXISTS
* - -ERR_MEMORY_STR GUID
* - -ERR_MALLOC_MEMORY
* - ERR_SUCCESS
*/
int GetInterfaceGUIDByIfIndex(const int ifIndex, GUID *pGuid);
/**
* @brief GUID
* @param[in] pInterfaceName
* @param[out] pGuid GUID
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_ITEM_UNEXISTS
* - -ERR_MEMORY_STR GUID
* - -ERR_MALLOC_MEMORY
* - ERR_SUCCESS
*/
int GetInterfaceGUIDByName(const TCHAR *pInterfaceName, GUID *pGuid);
int WaitNetAdapterConnected(const TCHAR *pInterfaceName, int timeOutOfMs);
/**
* @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
*/
int IsInternetConnectAdapter(int ifIndex, bool *pRet);
/**
* @brief NetworkCategory Private
* @param[in] pInterfaceName
* @param[out] pIsPrivate
* - TRUE Private
* - FALSE Public
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_CREATE_COMMOBJECT COM
* - -ERR_SYS_CALL COM
* - -ERR_ITEM_UNEXISTS
* - -ERR_MEMORY_STR
* - ERR_SUCCESS
*/
int GetNetConnectionNetworkCategory(const TCHAR *pInterfaceName, bool *pIsPrivate);
/**
* @brief / Windows
* @param[in] ifIndex
* @param[in] isEnable / Windows
* - TRUE
* - FALSE
* @param[in] isSetPrivate
* -TRUE
* -FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_CREATE_COMMOBJECT COM
* - -ERR_SYS_CALL COM
* - -ERR_ITEM_UNEXISTS GUID
* - -ERR_NET_UNCONNECT
* - ERR_SUCCESS
*/
int SetNetIntelnetConnectionSharing(int ifIndex, bool isEnable, bool isSetPrivate);
/**
* @brief
* @param[in] ifIndex
* @param[out] pIsEnable
* - TRUE
* - FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_CREATE_COMMOBJECT COM
* - -ERR_SYS_CALL COM
* - -ERR_ITEM_UNEXISTS GUID
* - -ERR_NET_UNCONNECT
* - -ERR_CALL_COMMOBJECT
* - ERR_SUCCESS
*/
int GetNetIntelnetConnectionSharing(int ifIndex, bool *pIsEnable);
/**
* @brief Private/Public
* @param[in] pInterfaceName pInterfaceName
* @param[in] isPrivate Category
* - TRUE Private
* - FALSE Public
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - -ERR_PROCESS_RETURN
* - ERR_SUCCESS
*/
int SetNetConnectionNetworkCategory(const TCHAR *pInterfaceName, const bool isPrivate);
/**
* @brief
* @param[in] pIP IP
* @param[in] pMask
* @param[in] pGateway
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_UN_SUPPORT IP地址转网络字节序网络地址失败
* - -ERR_NET_ADD_ROUTE
* - -ERR_NET_REMOVE_ROUTE
* - ERR_SUCCESS
*/
int AddRouteTable(const char *pIP, const char *pMask, const char *pGateway);
/**
* @brief Windows WireGuard NAT
* @param[in] pInterfaceName
* @param[in] pCidrIpaddr CIDR
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - -ERR_PROCESS_RETURN
* - ERR_SUCCESS
*/
int SetNATRule(const TCHAR *pInterfaceName, const TCHAR *pCidrIpaddr);
/**
* @brief Windows WireGuard NAT
* @param pInterfaceName
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - -ERR_PROCESS_RETURN
* - ERR_SUCCESS
*/
int RemoveNATRule(const TCHAR *pInterfaceName);
#if 0
/**
* @brief IP地址
* @param[in] pInterfaceName
* @param[in] pIpaddr IP
* @param[in] pNetmask
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - ERR_SUCCESS
*/
int SetInterfaceIpAddress(const TCHAR *pInterfaceName, const TCHAR *pIpaddr, const TCHAR *pNetmask);
/**
* @brief Windows Hyper-V NAT转发功能
* @param[out] pEnabled Hyper-V , TRUE , FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - ERR_SUCCESS
*/
int GetWindowsHyperVStatus(int *pEnabled);
/**
* @brief / Windows Hyper-V
* @param[in] enabled TRUE , FALSE
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - -ERR_PROCESS_RETURN
* - ERR_SUCCESS
*/
int EnableWindowsHyperV(bool enabled);
/**
* @brief Private/Public
* @param[in] pInterfaceName
* @param[in] isPrivate
* - TRUE Private
* - FALSE Public
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - -ERR_PROCESS_RETURN
* - ERR_SUCCESS
*/
int SetInterfacePrivate(const TCHAR *pInterfaceName, bool isPrivate);
/**
* @brief NetworkCategory Private
* @param[in] pInterfaceName
* @param[out] pIsPrivateMode
* - TRUE Private
* - FALSE Public
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_ITEM_UNEXISTS
* - -ERR_CALL_SHELL
* - -ERR_PROCESS_RETURN
* - ERR_SUCCESS
*/
int IsInterfacePrivate(const TCHAR *pInterfaceName, bool *pIsPrivateMode);
/**
* @brief
* @param[in] pInterfaceName
* @param[out] pIndex
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - ERR_SUCCESS
*/
int GetInterfaceIndexByName(const TCHAR *pInterfaceName, int *pIndex);
/**
* @brief
* @param[in] pInterfaceName
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - ERR_SUCCESS
*/
int RemoveInterfaceIpAddress(const TCHAR *pInterfaceName);
/**
* @brief IP地址
* @param[in] pInterfaceName
* @param[in] pCidrIpaddr CIDR类型IP地址
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - ERR_SUCCESS
*/
int SetInterfaceIpAddressFromCIDR(const TCHAR *pInterfaceName, const TCHAR *pCidrIpaddr);
/**
* @brief IP地址
* @param[in] pInterfaceName
* @param[in] pIpaddr IP
* @param[in] pNetmask
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MALLOC_MEMORY
* - -ERR_MEMORY_STR
* - -ERR_CALL_SHELL
* - ERR_SUCCESS
*/
int SetInterfaceIpAddress(const TCHAR *pInterfaceName, const TCHAR *pIpaddr, const TCHAR *pNetmask);
/**
* @brief NAT功能是否开启
* @param[in] pInterfaceName
* @param[out] pIsEnabled NAT当前是否开启
* - TRUE NAT
* - FALSE NAT
* @return 0: 0 @see USER_ERRNO
* - -ERR_INPUT_PARAMS
* - -ERR_MEMORY_STR
* - -ERR_ITEM_UNEXISTS
* - -ERR_CALL_SHELL
* - -ERR_PROCESS_RETURN
* - ERR_SUCCESS
*/
int IsNetConnectionSharingEnabled(const TCHAR *pInterfaceName, bool *pIsEnabled);
/**
* @brief WireGuard Windows PowerShell
* @return
* - TRUE
* - FALSE
*/
bool IsCustomNatPSCmdInstalled();
#endif
#ifdef __cplusplus
}
#endif