aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-03-22 09:44:42 +0100
committerHarald Welte <laforge@gnumonks.org>2019-04-24 15:43:26 +0200
commitaed46ec97d22c1eccae3578c0010840c3acede0e (patch)
tree6b45b1a357adabd50707859c32b79f67b8d29b07
parentd3dcaf0bf29b8380748f92e53822d264cc51c806 (diff)
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
-rw-r--r--include/osmocom/sgsn/gb_proxy.h21
-rw-r--r--src/gprs/gb_proxy.c8
-rw-r--r--src/gprs/gb_proxy_patch.c4
-rw-r--r--src/gprs/gb_proxy_tlli.c16
-rw-r--r--src/gprs/gb_proxy_vty.c22
5 files changed, 36 insertions, 35 deletions
diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h
index a3e1a0253..1e8fb253c 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 @@ enum gbproxy_match_id {
};
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 @@ struct gbproxy_config {
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 @@ struct gbproxy_peer {
/* 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 @@ struct gbproxy_tlli_state {
/* 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 @@ struct gbproxy_link_info {
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 @@ struct gbproxy_link_info {
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 0b5758a33..3da7bfdbb 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -310,7 +310,7 @@ static int gbproxy_restart_imsi_acquisition(struct gbproxy_link_info* link_info)
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 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer,
* 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 @@ static int block_unblock_peer(struct gbproxy_config *cfg, uint16_t ptp_bvci, uin
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 251bb67d6..6235b04f4 100644
--- a/src/gprs/gb_proxy_patch.c
+++ b/src/gprs/gb_proxy_patch.c
@@ -398,7 +398,7 @@ void gbproxy_clear_patch_filter(struct gbproxy_match *match)
{
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 @@ int gbproxy_set_patch_filter(struct gbproxy_match *match, const char *filter,
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 0c027d5fb..4e21ede86 100644
--- a/src/gprs/gb_proxy_tlli.c
+++ b/src/gprs/gb_proxy_tlli.c
@@ -284,8 +284,8 @@ void gbproxy_reassign_tlli(struct gbproxy_tlli_state *tlli_state,
/* 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 @@ static void gbproxy_validate_tlli(struct gbproxy_tlli_state *tlli_state,
/* 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 @@ static int gbproxy_unregister_link_info(struct gbproxy_peer *peer,
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 @@ static void gbproxy_assign_imsi(struct gbproxy_peer *peer,
&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 @@ static struct gbproxy_link_info *gbproxy_get_link_info_ul(
if (!link_info)
return NULL;
- link_info->is_deregistered = 0;
+ link_info->is_deregistered = false;
return link_info;
}
@@ -577,7 +577,7 @@ static struct gbproxy_link_info *gbproxy_get_link_info_dl(
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 52c39fdcd..5c4f45420 100644
--- a/src/gprs/gb_proxy_vty.c
+++ b/src/gprs/gb_proxy_vty.c
@@ -241,7 +241,7 @@ DEFUN(cfg_gbproxy_match_imsi,
return CMD_WARNING;
}
- g_cfg->acquire_imsi = 1;
+ g_cfg->acquire_imsi = true;
return CMD_SUCCESS;
}
@@ -256,7 +256,7 @@ DEFUN(cfg_gbproxy_no_match_imsi,
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 @@ DEFUN(cfg_gbproxy_patch_ptmsi,
"patch-ptmsi",
GBPROXY_PATCH_PTMSI_STR)
{
- g_cfg->patch_ptmsi = 1;
+ g_cfg->patch_ptmsi = true;
return CMD_SUCCESS;
}
@@ -339,7 +339,7 @@ DEFUN(cfg_gbproxy_no_patch_ptmsi,
"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 @@ DEFUN(cfg_gbproxy_acquire_imsi,
"acquire-imsi",
GBPROXY_ACQUIRE_IMSI_STR)
{
- g_cfg->acquire_imsi = 1;
+ g_cfg->acquire_imsi = true;
return CMD_SUCCESS;
}
@@ -365,7 +365,7 @@ DEFUN(cfg_gbproxy_no_acquire_imsi,
"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 @@ DEFUN(cfg_gbproxy_secondary_sgsn,
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 @@ DEFUN(cfg_gbproxy_no_secondary_sgsn,
"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 @@ DEFUN_DEPRECATED(cfg_gbproxy_broken_apn_match,
return CMD_WARNING;
}
- g_cfg->acquire_imsi = 1;
+ g_cfg->acquire_imsi = true;
return CMD_SUCCESS;
}