OpenVPN
Macros | Functions | Variables
wfp_block.c File Reference
#include "syshead.h"
#include <fwpmu.h>
#include <initguid.h>
#include <fwpmtypes.h>
#include <winsock2.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#include "wfp_block.h"
Include dependency graph for wfp_block.c:

Go to the source code of this file.

Macros

#define FWPM_SESSION_FLAG_DYNAMIC   0x00000001
 
#define OUT_ON_ERROR(err, msg)   if (err) { msg_handler(err, msg); goto out; }
 

Functions

 DEFINE_GUID (FWPM_LAYER_ALE_AUTH_CONNECT_V4, 0xc38d57d1, 0x05a7, 0x4c33, 0x90, 0x4f, 0x7f, 0xbc, 0xee, 0xe6, 0x0e, 0x82)
 
 DEFINE_GUID (FWPM_LAYER_ALE_AUTH_CONNECT_V6, 0x4a72393b, 0x319f, 0x44bc, 0x84, 0xc3, 0xba, 0x54, 0xdc, 0xb3, 0xb6, 0xb4)
 
 DEFINE_GUID (FWPM_CONDITION_ALE_APP_ID, 0xd78e1e87, 0x8644, 0x4ea5, 0x94, 0x37, 0xd8, 0x09, 0xec, 0xef, 0xc9, 0x71)
 
 DEFINE_GUID (FWPM_CONDITION_IP_REMOTE_PORT, 0xc35a604d, 0xd22b, 0x4e1a, 0x91, 0xb4, 0x68, 0xf6, 0x74, 0xee, 0x67, 0x4b)
 
 DEFINE_GUID (FWPM_CONDITION_IP_LOCAL_INTERFACE, 0x4cd62a49, 0x59c3, 0x4969, 0xb7, 0xf3, 0xbd, 0xa5, 0xd3, 0x28, 0x90, 0xa4)
 
 DEFINE_GUID (FWPM_CONDITION_FLAGS, 0x632ce23b, 0x5167, 0x435c, 0x86, 0xd7, 0xe9, 0x03, 0x68, 0x4a, 0xa8, 0x0c)
 
 DEFINE_GUID (OPENVPN_WFP_BLOCK_SUBLAYER, 0x2f660d7e, 0x6a37, 0x11e6, 0xa1, 0x81, 0x00, 0x1e, 0x8c, 0x6e, 0x04, 0xa2)
 
static void default_msg_handler (DWORD err, const char *msg)
 
static DWORD add_sublayer (GUID uuid)
 
DWORD add_wfp_block_filters (HANDLE *engine_handle, int index, const WCHAR *exe_path, wfp_block_msg_handler_t msg_handler, BOOL dns_only)
 
DWORD delete_wfp_block_filters (HANDLE engine_handle)
 
int get_interface_metric (const NET_IFINDEX index, const ADDRESS_FAMILY family, int *is_auto)
 Return interface metric value for the specified interface index. More...
 
DWORD set_interface_metric (const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric)
 Sets interface metric value for specified interface index. More...
 

Variables

static WCHAR * FIREWALL_NAME = L"OpenVPN"
 

Macro Definition Documentation

◆ FWPM_SESSION_FLAG_DYNAMIC

#define FWPM_SESSION_FLAG_DYNAMIC   0x00000001

Definition at line 48 of file wfp_block.c.

◆ OUT_ON_ERROR

#define OUT_ON_ERROR (   err,
  msg 
)    if (err) { msg_handler(err, msg); goto out; }

Definition at line 126 of file wfp_block.c.

Function Documentation

◆ add_sublayer()

static DWORD add_sublayer ( GUID  uuid)
static

Definition at line 133 of file wfp_block.c.

References FIREWALL_NAME.

Referenced by add_wfp_block_filters().

◆ add_wfp_block_filters()

DWORD add_wfp_block_filters ( HANDLE *  engine_handle,
int  index,
const WCHAR *  exe_path,
wfp_block_msg_handler_t  msg_handler,
BOOL  dns_only 
)

◆ default_msg_handler()

static void default_msg_handler ( DWORD  err,
const char *  msg 
)
inlinestatic

Definition at line 121 of file wfp_block.c.

Referenced by add_wfp_block_filters().

◆ DEFINE_GUID() [1/7]

DEFINE_GUID ( FWPM_CONDITION_ALE_APP_ID  ,
0xd78e1e87  ,
0x8644  ,
0x4ea5  ,
0x94  ,
0x37  ,
0xd8  ,
0x09  ,
0xec  ,
0xef  ,
0xc9  ,
0x71   
)

◆ DEFINE_GUID() [2/7]

DEFINE_GUID ( FWPM_CONDITION_FLAGS  ,
0x632ce23b  ,
0x5167  ,
0x435c  ,
0x86  ,
0xd7  ,
0xe9  ,
0x03  ,
0x68  ,
0x4a  ,
0xa8  ,
0x0c   
)

◆ DEFINE_GUID() [3/7]

DEFINE_GUID ( FWPM_CONDITION_IP_LOCAL_INTERFACE  ,
0x4cd62a49  ,
0x59c3  ,
0x4969  ,
0xb7  ,
0xf3  ,
0xbd  ,
0xa5  ,
0xd3  ,
0x28  ,
0x90  ,
0xa4   
)

◆ DEFINE_GUID() [4/7]

DEFINE_GUID ( FWPM_CONDITION_IP_REMOTE_PORT  ,
0xc35a604d  ,
0xd22b  ,
0x4e1a  ,
0x91  ,
0xb4  ,
0x68  ,
0xf6  ,
0x74  ,
0xee  ,
0x67  ,
0x4b   
)

◆ DEFINE_GUID() [5/7]

DEFINE_GUID ( FWPM_LAYER_ALE_AUTH_CONNECT_V4  ,
0xc38d57d1  ,
0x05a7  ,
0x4c33  ,
0x90  ,
0x4f  ,
0x7f  ,
0xbc  ,
0xee  ,
0xe6  ,
0x0e  ,
0x82   
)

◆ DEFINE_GUID() [6/7]

DEFINE_GUID ( FWPM_LAYER_ALE_AUTH_CONNECT_V6  ,
0x4a72393b  ,
0x319f  ,
0x44bc  ,
0x84  ,
0xc3  ,
0xba  ,
0x54  ,
0xdc  ,
0xb3  ,
0xb6  ,
0xb4   
)

◆ DEFINE_GUID() [7/7]

DEFINE_GUID ( OPENVPN_WFP_BLOCK_SUBLAYER  ,
0x2f660d7e  ,
0x6a37  ,
0x11e6  ,
0xa1  ,
0x81  ,
0x00  ,
0x1e  ,
0x8c  ,
0x6e  ,
0x04  ,
0xa2   
)

◆ delete_wfp_block_filters()

DWORD delete_wfp_block_filters ( HANDLE  engine_handle)

Definition at line 379 of file wfp_block.c.

Referenced by AddWfpBlock(), DeleteWfpBlock(), Undo(), and win_wfp_uninit().

◆ get_interface_metric()

int get_interface_metric ( const NET_IFINDEX  index,
const ADDRESS_FAMILY  family,
int *  is_auto 
)

Return interface metric value for the specified interface index.

Parameters
indexThe index of TAP adapter.
familyAddress family (AF_INET for IPv4 and AF_INET6 for IPv6).
is_autoOn return set to true if automatic metric is in use. Unused if NULL.
Returns
positive interface metric on success or -1 on error

Definition at line 404 of file wfp_block.c.

Referenced by adapter_index_of_ip(), AddWfpBlock(), and win_wfp_block().

◆ set_interface_metric()

DWORD set_interface_metric ( const NET_IFINDEX  index,
const ADDRESS_FAMILY  family,
const ULONG  metric 
)

Sets interface metric value for specified interface index.

Parameters
indexThe index of TAP adapter
familyAddress family (AF_INET for IPv4 and AF_INET6 for IPv6)
metricMetric value. 0 for automatic metric
Returns
0 on success, a non-zero status code of the last failed action on failure.

Definition at line 443 of file wfp_block.c.

Referenced by AddWfpBlock(), DeleteWfpBlock(), Undo(), win_wfp_block(), and win_wfp_uninit().

Variable Documentation

◆ FIREWALL_NAME

WCHAR* FIREWALL_NAME = L"OpenVPN"
static

Definition at line 115 of file wfp_block.c.

Referenced by add_sublayer(), and add_wfp_block_filters().