gb_proxy: cosmetic: Use 'bool' in data structures where applicable
If we ever only use 0/1 in an 'int', we should have used 'bool'.
Change-Id: I63876f52d5de87e4c99d92669270fd1f487e217c
diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h
index a3e1a02..1e8fb25 100644
--- a/include/osmocom/sgsn/gb_proxy.h
+++ b/include/osmocom/sgsn/gb_proxy.h
@@ -10,6 +10,7 @@
#include <sys/types.h>
#include <regex.h>
+#include <stdbool.h>
#define GBPROXY_INIT_VU_GEN_TX 256
@@ -83,7 +84,7 @@
};
struct gbproxy_match {
- int enable; /* is this match enabled? */
+ bool enable; /* is this match enabled? */
char *re_str; /* regular expression (for IMSI) in string format */
regex_t re_comp; /* compiled regular expression (for IMSI) */
};
@@ -119,11 +120,11 @@
uint32_t stored_msgs_max_len;
/* Should the P-TMSI be patched on the fly (required for 2-SGSN config) */
- int patch_ptmsi;
+ bool patch_ptmsi;
/* Should the IMSI be acquired by the proxy (required for 2-SGSN config) */
- int acquire_imsi;
+ bool acquire_imsi;
/* Should we route subscribers to two different SGSNs? */
- int route_to_sgsn2;
+ bool route_to_sgsn2;
/* NSEI of the second SGSN */
uint16_t nsip_sgsn2_nsei;
/* should we keep a cache of per-subscriber state even after de-registration? */
@@ -154,7 +155,7 @@
/* BVCI used for Point-to-Point to this peer */
uint16_t bvci;
- int blocked;
+ bool blocked;
/* Routeing Area that this peer is part of (raw 04.08 encoding) */
uint8_t ra[6];
@@ -175,9 +176,9 @@
/* newly-assigned TLLI (e.g. during P-TMSI allocation procedure) */
uint32_t assigned;
/* has the BSS side validated (confirmed) the new TLLI? */
- int bss_validated;
+ bool bss_validated;
/* has the SGSN side validated (confirmed) the new TLLI? */
- int net_validated;
+ bool net_validated;
/* NOTE: once both are validated, we set current = assigned and assigned = 0 */
/* The P-TMSI for this subscriber */
@@ -204,7 +205,7 @@
size_t imsi_len;
/* is the IMSI acquisition still pending? */
- int imsi_acq_pending;
+ bool imsi_acq_pending;
/* queue of stored UL messages (until IMSI acquisition completes and we can
* determine which of the SGSNs we should route this to */
@@ -215,10 +216,10 @@
unsigned vu_gen_tx_bss;
/* is this subscriber deregistered (TLLI invalidated)? */
- int is_deregistered;
+ bool is_deregistered;
/* does this link match either the (2-SGSN) routing or the patching rule? */
- int is_matching[GBPROX_MATCH_LAST];
+ bool is_matching[GBPROX_MATCH_LAST];
};
diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index 0b5758a..3da7bfd 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -310,7 +310,7 @@
in_progress = 1;
gbproxy_link_info_discard_messages(link_info);
- link_info->imsi_acq_pending = 0;
+ link_info->imsi_acq_pending = false;
return in_progress;
}
@@ -531,7 +531,7 @@
* implementation relies on the MS doing proper retransmissions
* of the triggering message instead */
- link_info->imsi_acq_pending = 1;
+ link_info->imsi_acq_pending = true;
}
return 0;
@@ -836,11 +836,11 @@
switch (pdu_type) {
case BSSGP_PDUT_BVC_BLOCK_ACK:
- peer->blocked = 1;
+ peer->blocked = true;
rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_BLOCKED]);
break;
case BSSGP_PDUT_BVC_UNBLOCK_ACK:
- peer->blocked = 0;
+ peer->blocked = false;
rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_UNBLOCKED]);
break;
default:
diff --git a/src/gprs/gb_proxy_patch.c b/src/gprs/gb_proxy_patch.c
index 251bb67..6235b04 100644
--- a/src/gprs/gb_proxy_patch.c
+++ b/src/gprs/gb_proxy_patch.c
@@ -398,7 +398,7 @@
{
if (match->enable) {
regfree(&match->re_comp);
- match->enable = 0;
+ match->enable = false;
}
talloc_free(match->re_str);
match->re_str = NULL;
@@ -419,7 +419,7 @@
REG_EXTENDED | REG_NOSUB | REG_ICASE);
if (rc == 0) {
- match->enable = 1;
+ match->enable = true;
match->re_str = talloc_strdup(tall_sgsn_ctx, filter);
return 0;
}
diff --git a/src/gprs/gb_proxy_tlli.c b/src/gprs/gb_proxy_tlli.c
index 0c027d5..4e21ede 100644
--- a/src/gprs/gb_proxy_tlli.c
+++ b/src/gprs/gb_proxy_tlli.c
@@ -284,8 +284,8 @@
/* Remember assigned TLLI */
tlli_state->assigned = new_tlli;
- tlli_state->bss_validated = 0;
- tlli_state->net_validated = 0;
+ tlli_state->bss_validated = false;
+ tlli_state->net_validated = false;
}
uint32_t gbproxy_map_tlli(uint32_t other_tlli,
@@ -325,9 +325,9 @@
/* See GSM 04.08, 4.7.1.5 */
if (to_bss)
- tlli_state->net_validated = 1;
+ tlli_state->net_validated = true;
else
- tlli_state->bss_validated = 1;
+ tlli_state->bss_validated = true;
if (!tlli_state->bss_validated || !tlli_state->net_validated)
return;
@@ -367,7 +367,7 @@
link_info->sgsn_tlli.current = 0;
link_info->sgsn_tlli.assigned = 0;
- link_info->is_deregistered = 1;
+ link_info->is_deregistered = true;
gbproxy_reset_link(link_info);
@@ -424,7 +424,7 @@
&peer->cfg->matches[match_id],
parse_ctx->imsi, parse_ctx->imsi_len);
if (imsi_matches >= 0)
- link_info->is_matching[match_id] = imsi_matches;
+ link_info->is_matching[match_id] = imsi_matches ? true : false;
}
}
@@ -498,7 +498,7 @@
if (!link_info)
return NULL;
- link_info->is_deregistered = 0;
+ link_info->is_deregistered = false;
return link_info;
}
@@ -577,7 +577,7 @@
peer, parse_ctx->imsi, parse_ctx->imsi_len);
if (link_info)
- link_info->is_deregistered = 0;
+ link_info->is_deregistered = false;
return link_info;
}
diff --git a/src/gprs/gb_proxy_vty.c b/src/gprs/gb_proxy_vty.c
index 52c39fd..5c4f454 100644
--- a/src/gprs/gb_proxy_vty.c
+++ b/src/gprs/gb_proxy_vty.c
@@ -241,7 +241,7 @@
return CMD_WARNING;
}
- g_cfg->acquire_imsi = 1;
+ g_cfg->acquire_imsi = true;
return CMD_SUCCESS;
}
@@ -256,7 +256,7 @@
for (match_id = 0; match_id < ARRAY_SIZE(g_cfg->matches); ++match_id)
gbproxy_clear_patch_filter(&g_cfg->matches[match_id]);
- g_cfg->acquire_imsi = 0;
+ g_cfg->acquire_imsi = false;
return CMD_SUCCESS;
}
@@ -329,7 +329,7 @@
"patch-ptmsi",
GBPROXY_PATCH_PTMSI_STR)
{
- g_cfg->patch_ptmsi = 1;
+ g_cfg->patch_ptmsi = true;
return CMD_SUCCESS;
}
@@ -339,7 +339,7 @@
"no patch-ptmsi",
NO_STR GBPROXY_PATCH_PTMSI_STR)
{
- g_cfg->patch_ptmsi = 0;
+ g_cfg->patch_ptmsi = false;
return CMD_SUCCESS;
}
@@ -355,7 +355,7 @@
"acquire-imsi",
GBPROXY_ACQUIRE_IMSI_STR)
{
- g_cfg->acquire_imsi = 1;
+ g_cfg->acquire_imsi = true;
return CMD_SUCCESS;
}
@@ -365,7 +365,7 @@
"no acquire-imsi",
NO_STR GBPROXY_ACQUIRE_IMSI_STR)
{
- g_cfg->acquire_imsi = 0;
+ g_cfg->acquire_imsi = false;
return CMD_SUCCESS;
}
@@ -387,10 +387,10 @@
return CMD_WARNING;
}
- g_cfg->route_to_sgsn2 = 1;
+ g_cfg->route_to_sgsn2 = true;
g_cfg->nsip_sgsn2_nsei = nsei;
- g_cfg->patch_ptmsi = 1;
+ g_cfg->patch_ptmsi = true;
return CMD_SUCCESS;
}
@@ -400,10 +400,10 @@
"no secondary-sgsn",
NO_STR GBPROXY_SECOND_SGSN_STR)
{
- g_cfg->route_to_sgsn2 = 0;
+ g_cfg->route_to_sgsn2 = false;
g_cfg->nsip_sgsn2_nsei = 0xFFFF;
- g_cfg->patch_ptmsi = 0;
+ g_cfg->patch_ptmsi = false;
return CMD_SUCCESS;
}
@@ -849,7 +849,7 @@
return CMD_WARNING;
}
- g_cfg->acquire_imsi = 1;
+ g_cfg->acquire_imsi = true;
return CMD_SUCCESS;
}