Skip to content

Commit 93b4db8

Browse files
committed
Minor fixes.
1 parent 3a4385b commit 93b4db8

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

src/firewall.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ GCC_PRAGMA (GCC diagnostic ignored "-Wmissing-braces")
141141

142142
/**
143143
* \def FW_FUNC_ENOSYS
144-
* The error-code (120) to use if `g_cfg.FIREWALL.enable == FALSE`.
144+
* The error-code (120) to use if `g_cfg.FIREWALL.enable == false`.
145145
*/
146146
#define FW_FUNC_ENOSYS ERROR_CALL_NOT_IMPLEMENTED
147147

@@ -180,7 +180,7 @@ static int fw_api = FW_API_DEFAULT;
180180
static bool fw_force_init = false;
181181

182182
/**
183-
* TRUE if we've been called from `firewall_main()`.
183+
* `true` if we've been called from `firewall_main()`.
184184
*/
185185
static bool from_firewall_main = false;
186186

@@ -1239,7 +1239,7 @@ DEF_FUNC (ULONG, FWClosePolicyStore, (HANDLE *policy_store));
12391239
* Add the function-pointer value `p_XXfunc` to the `fw_funcs[]` array.
12401240
*/
12411241
#undef ADD_VALUE
1242-
#define ADD_VALUE(dll, func) { TRUE, NULL, dll, #func, (void**)&p_##func }
1242+
#define ADD_VALUE(dll, func) { true, NULL, dll, #func, (void**)&p_##func }
12431243

12441244
static struct LoadTable fw_funcs[] = {
12451245
ADD_VALUE ("FirewallAPI.dll", FWOpenPolicyStore),
@@ -2028,7 +2028,7 @@ static bool fw_monitor_init (_FWPM_NET_EVENT_SUBSCRIPTION0 *subscription)
20282028
FWP_VALUE value;
20292029
DWORD rc;
20302030

2031-
/* If 'fw_init()' wasn't called or succeeded, return FALSE.
2031+
/* If 'fw_init()' wasn't called or succeeded, return false.
20322032
*/
20332033
if (fw_policy_handle == INVALID_HANDLE_VALUE)
20342034
{
@@ -2095,7 +2095,7 @@ static bool fw_monitor_init (_FWPM_NET_EVENT_SUBSCRIPTION0 *subscription)
20952095
}
20962096

20972097
/**
2098-
* Try all available `FwpmNetEventSubscribeX()` functions and return TRUE if one succeedes.
2098+
* Try all available `FwpmNetEventSubscribeX()` functions and return `true` if one succeedes.
20992099
* Start with the one above or equal the given API-level in `fw_api`.
21002100
*/
21012101
static bool fw_monitor_subscribe (_FWPM_NET_EVENT_SUBSCRIPTION0 *subscription)
@@ -2631,7 +2631,7 @@ static int rule_compare_name (const void **_a, const void **_b)
26312631
* ```
26322632
* HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Defaults\FirewallPolicy\FirewallRules
26332633
* ```
2634-
* and if `g_cfg.FIREWALL.show_all == TRUE`:
2634+
* and if `g_cfg.FIREWALL.show_all == true`:
26352635
* ```
26362636
* HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules"
26372637
* ```
@@ -4266,9 +4266,9 @@ static void print_eff_name_id (const _FWPM_NET_EVENT_HEADER3 *header)
42664266
* Lookup the account and domain for a SID to get
42674267
* a more sensible account and domain-name.
42684268
*
4269-
* \retval TRUE The account and domain for the SID was found.
4270-
* Also returns TRUE if there is no mapping of the SID.
4271-
* \retval FALSE The account and domain for the SID was not found.
4269+
* \retval true The account and domain for the SID was found.
4270+
* Also returns `true` if there is no mapping of the SID.
4271+
* \retval false The account and domain for the SID was not found.
42724272
*/
42734273
static bool lookup_account_SID (const SID *sid, const char *sid_str, char *account, char *domain)
42744274
{
@@ -4414,6 +4414,16 @@ static void print_reauth_reason (const _FWPM_NET_EVENT_HEADER3 *header,
44144414
else fw_buf_addf ("%lu\n", DWORD_CAST(allow_event->reauthReason));
44154415
}
44164416

4417+
/*
4418+
* Map a 'FWP_IP_VERSION_V4' / 'FWP_IP_VERSION_V6'
4419+
* to "4", "6" or "?".
4420+
*/
4421+
static const char *ip_ver_str (int fw_ip_ver)
4422+
{
4423+
return (fw_ip_ver == FWP_IP_VERSION_V4 ? "4" :
4424+
fw_ip_ver == FWP_IP_VERSION_V6 ? "6" : "?");
4425+
}
4426+
44174427
static void CALLBACK
44184428
fw_event_callback (const UINT event_type,
44194429
const _FWPM_NET_EVENT_HEADER3 *header,
@@ -4449,7 +4459,7 @@ static void CALLBACK
44494459
(header->ipVersion == FWP_IP_VERSION_V6 && !g_cfg.FIREWALL.show_ipv6))
44504460
{
44514461
fw_num_ignored++;
4452-
TRACE (2, "Ignoring IPv%d event.\n", header->ipVersion);
4462+
TRACE (2, "Ignoring IPv%s event.\n", ip_ver_str(header->ipVersion));
44534463
return;
44544464
}
44554465
}
@@ -4459,7 +4469,7 @@ static void CALLBACK
44594469
* of `exclude_list_get (address_str, EXCL_ADDRESS)` before deciding to print anything.
44604470
* The same goes for `exclude_list_get (appId, EXCL_PROGRAM)`.
44614471
*
4462-
* If all `X_printed` are `FALSE`, `fw_buf_reset()` is called and nothing gets printed to `C_puts()`.
4472+
* If all `X_printed` are `false`, `fw_buf_reset()` is called and nothing gets printed to `C_puts()`.
44634473
*/
44644474
event_name = list_lookup_name (event_type, events, DIM(events));
44654475

@@ -4796,7 +4806,8 @@ int firewall_main (int argc, char **argv)
47964806

47974807
set_program_name (argv[0]);
47984808

4799-
g_cfg.FIREWALL.show_ipv6 = false; /* override the config-file */
4809+
g_cfg.FIREWALL.show_ipv6 = false; /* override the config-file */
4810+
g_cfg.FIREWALL.show_all = false; /* ditto */
48004811

48014812
while ((ch = getopt(argc, argv, "46a:Afh?cel:prRstv")) != EOF)
48024813
switch (ch)
@@ -4862,8 +4873,8 @@ int firewall_main (int argc, char **argv)
48624873

48634874
program = set_net_program (argc-optind, argv+optind);
48644875

4865-
g_cfg.FIREWALL.enable = true; /* should be redundant */
4866-
g_cfg.trace_report = true; /* enable statistics in 'fw_report()' */
4876+
g_cfg.FIREWALL.enable = true; /* should be redundant */
4877+
g_cfg.trace_report = true; /* enable statistics in 'fw_report()' */
48674878

48684879
if (dump_events || dump_rules || dump_callouts || log_file ||
48694880
g_data.stdout_redirected || g_cfg.trace_use_ods)

src/init.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct FIREWALL_cfg {
124124
};
125125

126126
/**
127-
* Keep ALL user-configurable data to this structure:
127+
* Keep ALL user-configurable data in this structure:
128128
*/
129129
struct config_table {
130130
char *trace_file;
@@ -209,7 +209,7 @@ struct config_table {
209209
extern struct config_table g_cfg;
210210

211211
/**
212-
* Keep ALL other global data to this structure:
212+
* Keep ALL other global data in this structure:
213213
*/
214214
struct global_data {
215215
bool fatal_error;

0 commit comments

Comments
 (0)