OpenVPN
Macros | Functions | Variables
block_dns.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 "block_dns.h"
Include dependency graph for block_dns.c:

Go to the source code of this file.

Macros

#define FWPM_SESSION_FLAG_DYNAMIC   0x00000001
 
#define CHECK_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 (OPENVPN_BLOCK_OUTSIDE_DNS_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_block_dns_filters (HANDLE *engine_handle, int index, const WCHAR *exe_path, block_dns_msg_handler_t msg_handler)
 
DWORD delete_block_dns_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

◆ CHECK_ERROR

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

Definition at line 116 of file block_dns.c.

◆ FWPM_SESSION_FLAG_DYNAMIC

#define FWPM_SESSION_FLAG_DYNAMIC   0x00000001

Definition at line 47 of file block_dns.c.

Function Documentation

◆ add_block_dns_filters()

DWORD add_block_dns_filters ( HANDLE *  engine_handle,
int  index,
const WCHAR *  exe_path,
block_dns_msg_handler_t  msg_handler 
)

◆ add_sublayer()

static DWORD add_sublayer ( GUID  uuid)
static

Definition at line 123 of file block_dns.c.

References FIREWALL_NAME.

Referenced by add_block_dns_filters().

◆ default_msg_handler()

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

Definition at line 111 of file block_dns.c.

Referenced by add_block_dns_filters().

◆ DEFINE_GUID() [1/6]

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

◆ DEFINE_GUID() [2/6]

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

◆ DEFINE_GUID() [3/6]

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

◆ DEFINE_GUID() [4/6]

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

◆ DEFINE_GUID() [5/6]

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

◆ DEFINE_GUID() [6/6]

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

◆ delete_block_dns_filters()

DWORD delete_block_dns_filters ( HANDLE  engine_handle)

Definition at line 325 of file block_dns.c.

Referenced by AddBlockDNS(), DeleteBlockDNS(), 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 350 of file block_dns.c.

Referenced by adapter_index_of_ip(), AddBlockDNS(), and win_wfp_block_dns().

◆ 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 389 of file block_dns.c.

Referenced by AddBlockDNS(), DeleteBlockDNS(), Undo(), win_wfp_block_dns(), and win_wfp_uninit().

Variable Documentation

◆ FIREWALL_NAME

WCHAR* FIREWALL_NAME = L"OpenVPN"
static

Definition at line 105 of file block_dns.c.

Referenced by add_block_dns_filters(), and add_sublayer().