OpenVPN
Data Structures | Functions
tap.h File Reference
#include <windows.h>
#include "basic.h"
Include dependency graph for tap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tap_interface_node
 Network interface list node. More...
 

Functions

DWORD tap_create_interface (_In_opt_ HWND hwndParent, _In_opt_ LPCTSTR szDeviceDescription, _Inout_ LPBOOL pbRebootRequired, _Out_ LPGUID pguidInterface)
 Creates a TUN/TAP interface. More...
 
DWORD tap_delete_interface (_In_opt_ HWND hwndParent, _In_ LPCGUID pguidInterface, _Inout_ LPBOOL pbRebootRequired)
 Deletes an interface. More...
 
DWORD tap_set_interface_name (_In_ LPCGUID pguidInterface, _In_ LPCTSTR szName)
 Sets interface name. More...
 
DWORD tap_list_interfaces (_In_opt_ HWND hwndParent, _Out_ struct tap_interface_node **ppInterfaceList, _In_ BOOL bAll)
 Creates a list of available network interfaces. More...
 
void tap_free_interface_list (_In_ struct tap_interface_node *pInterfaceList)
 Frees a list of network interfaces. More...
 

Function Documentation

◆ tap_create_interface()

DWORD tap_create_interface ( _In_opt_ HWND  hwndParent,
_In_opt_ LPCTSTR  szDeviceDescription,
_Inout_ LPBOOL  pbRebootRequired,
_Out_ LPGUID  pguidInterface 
)

Creates a TUN/TAP interface.

Parameters
hwndParentA handle to the top-level window to use for any user interface that is related to non-device-specific actions (such as a select-device dialog box that uses the global class driver list). This handle is optional and can be NULL. If a specific top-level window is not required, set hwndParent to NULL.
szDeviceDescriptionA pointer to a NULL-terminated string that supplies the text description of the device. This pointer is optional and can be NULL.
pbRebootRequiredA pointer to a BOOL flag. If the interface installation requires a system restart, this flag is set to TRUE. Otherwise, the flag is left unmodified. This allows the flag to be globally initialized to FALSE and reused for multiple interface installations.
pguidInterfaceA pointer to GUID that receives network interface ID.
Returns
ERROR_SUCCESS on success; Win32 error code otherwise

Definition at line 448 of file tap.c.

References check_reboot(), free, get_net_interface_guid(), GUID_DEVCLASS_NET, M_ERRNO, M_FATAL, M_NONFATAL, M_WARN, malloc, msg, PRIsLPTSTR, and szzHardwareIDs.

Referenced by _tmain(), and msica_op_tap_interface_create_exec().

◆ tap_delete_interface()

DWORD tap_delete_interface ( _In_opt_ HWND  hwndParent,
_In_ LPCGUID  pguidInterface,
_Inout_ LPBOOL  pbRebootRequired 
)

Deletes an interface.

Parameters
hwndParentA handle to the top-level window to use for any user interface that is related to non-device-specific actions (such as a select-device dialog box that uses the global class driver list). This handle is optional and can be NULL. If a specific top-level window is not required, set hwndParent to NULL.
pguidInterfaceA pointer to GUID that contains network interface ID.
pbRebootRequiredA pointer to a BOOL flag. If the interface installation requires a system restart, this flag is set to TRUE. Otherwise, the flag is left unmodified. This allows the flag to be globally initialized to FALSE and reused for multiple interface installations.
Returns
ERROR_SUCCESS on success; Win32 error code otherwise

Definition at line 753 of file tap.c.

References check_reboot(), get_net_interface_guid(), GUID_DEVCLASS_NET, M_ERRNO, M_NONFATAL, M_WARN, msg, and PRIsLPOLESTR.

Referenced by _tmain(), msica_op_tap_interface_create_exec(), and msica_op_tap_interface_delete().

◆ tap_free_interface_list()

void tap_free_interface_list ( _In_ struct tap_interface_node pInterfaceList)

Frees a list of network interfaces.

Parameters
pInterfaceListA pointer to the first interface in the list to free.

Definition at line 1163 of file tap.c.

References free, and tap_interface_node::pNext.

Referenced by _tmain(), FindTAPInterfaces(), msica_op_tap_interface_create_exec(), msica_op_tap_interface_delete_by_guid_exec(), msica_op_tap_interface_delete_by_name_exec(), and msica_op_tap_interface_set_name_exec().

◆ tap_list_interfaces()

DWORD tap_list_interfaces ( _In_opt_ HWND  hwndParent,
_Out_ struct tap_interface_node **  ppInterfaceList,
_In_ BOOL  bAll 
)

Creates a list of available network interfaces.

Parameters
hwndParentA handle to the top-level window to use for any user interface that is related to non-device-specific actions (such as a select-device dialog box that uses the global class driver list). This handle is optional and can be NULL. If a specific top-level window is not required, set hwndParent to NULL.
ppInterfaceListA pointer to the list to receive pointer to the first interface in the list. After the list is no longer required, free it using tap_free_interface_list().
bAllWhen TRUE, all network interfaces found are added to the list. When FALSE, only TUN/TAP interfaces found are added.
Returns
ERROR_SUCCESS on success; Win32 error code otherwise

Definition at line 954 of file tap.c.

References _tcszlen(), free, get_device_reg_property(), get_net_interface_guid(), get_reg_string(), tap_interface_node::guid, GUID_DEVCLASS_NET, INTERFACE_REGKEY_PATH_MAX, M_ERRNO, M_FATAL, M_NONFATAL, M_WARN, malloc, msg, tap_interface_node::pNext, PRIsLPOLESTR, PRIsLPTSTR, szInterfaceRegKeyPathTemplate, szName, tap_interface_node::szName, szzHardwareIDs, and tap_interface_node::szzHardwareIDs.

Referenced by _tmain(), FindTAPInterfaces(), msica_op_tap_interface_create_exec(), msica_op_tap_interface_delete_by_guid_exec(), msica_op_tap_interface_delete_by_name_exec(), and msica_op_tap_interface_set_name_exec().

◆ tap_set_interface_name()

DWORD tap_set_interface_name ( _In_ LPCGUID  pguidInterface,
_In_ LPCTSTR  szName 
)

Sets interface name.

Parameters
pguidInterfaceA pointer to GUID that contains network interface ID.
szNameNew interface name - must be unique
Returns
ERROR_SUCCESS on success; Win32 error code otherwise

Definition at line 878 of file tap.c.

References GUID_DEVCLASS_NET, INTERFACE_REGKEY_PATH_MAX, M_ERRNO, M_NONFATAL, msg, PRIsLPTSTR, and szInterfaceRegKeyPathTemplate.

Referenced by _tmain(), msica_op_tap_interface_create_exec(), and msica_op_tap_interface_set_name_exec().