gbproxy: Remove patch_mode, update initial checks
This patch removes the patch_mode feature including the related VTY command patch-mode. Where sensible, the other configuration flags are queried instead. In addition, this initial checks in gbprox_process_bssgp_dl() and gbprox_process_bssgp_ul() have been updated. The patch mode feature has not been used and was increasingly difficult to maintain. Sponsored-by: On-Waves ehf
This commit is contained in:
parent
7fb26c2943
commit
1abfdc218e
|
@ -14,16 +14,6 @@ struct rate_ctr_group;
|
|||
struct gprs_gb_parse_context;
|
||||
struct tlv_parsed;
|
||||
|
||||
enum gbproxy_patch_mode {
|
||||
GBPROX_PATCH_DEFAULT,
|
||||
GBPROX_PATCH_BSSGP, /*!< BSGGP messages only */
|
||||
GBPROX_PATCH_LLC_ATTACH_REQ, /*!< BSSGP and Attach Request */
|
||||
GBPROX_PATCH_LLC_ATTACH, /*!< BSSGP and Attach Request/Response */
|
||||
GBPROX_PATCH_LLC_GMM, /*!< BSSGP and all GMM msgs */
|
||||
GBPROX_PATCH_LLC_GSM, /*!< BSSGP and all GMM and GSM msgs */
|
||||
GBPROX_PATCH_LLC, /*!< BSSGP and all supported LLC msgs */
|
||||
};
|
||||
|
||||
enum gbproxy_global_ctr {
|
||||
GBPROX_GLOB_CTR_INV_BVCI,
|
||||
GBPROX_GLOB_CTR_INV_LAI,
|
||||
|
@ -79,7 +69,6 @@ struct gbproxy_config {
|
|||
uint8_t* core_apn;
|
||||
size_t core_apn_size;
|
||||
char * match_re;
|
||||
enum gbproxy_patch_mode patch_mode;
|
||||
int tlli_max_age;
|
||||
int tlli_max_len;
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg,
|
|||
int send_msg_directly = 0;
|
||||
|
||||
if (!cfg->core_mcc && !cfg->core_mnc && !cfg->core_apn &&
|
||||
!cfg->acquire_imsi)
|
||||
!cfg->acquire_imsi && !cfg->patch_ptmsi && !cfg->route_to_sgsn2)
|
||||
return 1;
|
||||
|
||||
parse_ctx.to_bss = 0;
|
||||
|
@ -483,6 +483,10 @@ static void gbprox_process_bssgp_dl(struct gbproxy_config *cfg,
|
|||
time_t now;
|
||||
struct gbproxy_tlli_info *tlli_info = NULL;
|
||||
|
||||
if (!cfg->core_mcc && !cfg->core_mnc && !cfg->core_apn &&
|
||||
!cfg->acquire_imsi && !cfg->patch_ptmsi && !cfg->route_to_sgsn2)
|
||||
return;
|
||||
|
||||
parse_ctx.to_bss = 1;
|
||||
|
||||
rc = gprs_gb_parse_bssgp(msgb_bssgph(msg), msgb_bssgp_len(msg),
|
||||
|
|
|
@ -29,37 +29,6 @@
|
|||
#include <osmocom/gprs/protocol/gsm_08_18.h>
|
||||
#include <osmocom/core/rate_ctr.h>
|
||||
|
||||
/* check whether patching is enabled at this level */
|
||||
static int patching_is_enabled(struct gbproxy_peer *peer,
|
||||
enum gbproxy_patch_mode need_at_least)
|
||||
{
|
||||
enum gbproxy_patch_mode patch_mode = peer->cfg->patch_mode;
|
||||
if (patch_mode == GBPROX_PATCH_DEFAULT)
|
||||
patch_mode = GBPROX_PATCH_LLC;
|
||||
|
||||
return need_at_least <= patch_mode;
|
||||
}
|
||||
|
||||
/* check whether patching is enabled at this level */
|
||||
static int patching_is_required(struct gbproxy_peer *peer,
|
||||
enum gbproxy_patch_mode need_at_least)
|
||||
{
|
||||
return need_at_least <= peer->cfg->patch_mode;
|
||||
}
|
||||
|
||||
static int allow_message_patching(struct gbproxy_peer *peer, int msg_type)
|
||||
{
|
||||
if (msg_type >= GSM48_MT_GSM_ACT_PDP_REQ) {
|
||||
return patching_is_enabled(peer, GBPROX_PATCH_LLC_GSM);
|
||||
} else if (msg_type > GSM48_MT_GMM_ATTACH_REJ) {
|
||||
return patching_is_enabled(peer, GBPROX_PATCH_LLC);
|
||||
} else if (msg_type > GSM48_MT_GMM_ATTACH_REQ) {
|
||||
return patching_is_enabled(peer, GBPROX_PATCH_LLC_ATTACH);
|
||||
} else {
|
||||
return patching_is_enabled(peer, GBPROX_PATCH_LLC_ATTACH_REQ);
|
||||
}
|
||||
}
|
||||
|
||||
/* patch RA identifier in place */
|
||||
static void gbproxy_patch_raid(uint8_t *raid_enc, struct gbproxy_peer *peer,
|
||||
int to_bss, const char *log_text)
|
||||
|
@ -230,9 +199,6 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len,
|
|||
int have_patched = 0;
|
||||
int fcs;
|
||||
|
||||
if (parse_ctx->g48_hdr && !allow_message_patching(peer, parse_ctx->g48_hdr->msg_type))
|
||||
return have_patched;
|
||||
|
||||
if (parse_ctx->ptmsi_enc && tlli_info) {
|
||||
uint32_t ptmsi;
|
||||
if (parse_ctx->to_bss)
|
||||
|
@ -314,18 +280,12 @@ void gbproxy_patch_bssgp(struct msgb *msg, uint8_t *bssgp, size_t bssgp_len,
|
|||
const char *err_info = NULL;
|
||||
int err_ctr = -1;
|
||||
|
||||
if (!patching_is_enabled(peer, GBPROX_PATCH_BSSGP))
|
||||
return;
|
||||
|
||||
if (parse_ctx->bssgp_raid_enc)
|
||||
gbproxy_patch_raid(parse_ctx->bssgp_raid_enc, peer,
|
||||
parse_ctx->to_bss, "BSSGP");
|
||||
|
||||
if (!patching_is_enabled(peer, GBPROX_PATCH_LLC_ATTACH_REQ))
|
||||
return;
|
||||
|
||||
if (parse_ctx->need_decryption &&
|
||||
patching_is_required(peer, GBPROX_PATCH_LLC_ATTACH)) {
|
||||
(peer->cfg->patch_ptmsi || peer->cfg->core_apn)) {
|
||||
/* Patching LLC messages has been requested
|
||||
* explicitly, but the message (including the
|
||||
* type) is encrypted, so we possibly fail to
|
||||
|
|
|
@ -50,17 +50,6 @@ static struct cmd_node gbproxy_node = {
|
|||
1,
|
||||
};
|
||||
|
||||
static const struct value_string patch_modes[] = {
|
||||
{GBPROX_PATCH_DEFAULT, "default"},
|
||||
{GBPROX_PATCH_BSSGP, "bssgp"},
|
||||
{GBPROX_PATCH_LLC_ATTACH_REQ, "llc-attach-req"},
|
||||
{GBPROX_PATCH_LLC_ATTACH, "llc-attach"},
|
||||
{GBPROX_PATCH_LLC_GMM, "llc-gmm"},
|
||||
{GBPROX_PATCH_LLC_GSM, "llc-gsm"},
|
||||
{GBPROX_PATCH_LLC, "llc"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static void gbprox_vty_print_peer(struct vty *vty, struct gbproxy_peer *peer)
|
||||
{
|
||||
struct gprs_ra_id raid;
|
||||
|
@ -118,11 +107,6 @@ static int config_write_gbproxy(struct vty *vty)
|
|||
vty_out(vty, " tlli-list max-length %d%s",
|
||||
g_cfg->tlli_max_len, VTY_NEWLINE);
|
||||
|
||||
if (g_cfg->patch_mode != GBPROX_PATCH_DEFAULT)
|
||||
vty_out(vty, " patch-mode %s%s",
|
||||
get_value_string(patch_modes, g_cfg->patch_mode),
|
||||
VTY_NEWLINE);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -415,25 +399,6 @@ DEFUN(cfg_gbproxy_tlli_list_no_max_len,
|
|||
}
|
||||
|
||||
|
||||
DEFUN(cfg_gbproxy_patch_mode,
|
||||
cfg_gbproxy_patch_mode_cmd,
|
||||
"patch-mode (default|bssgp|llc-attach-req|llc-attach|llc-gmm|llc-gsm|llc)",
|
||||
"Set patch mode\n"
|
||||
"Use build-in default (best effort, try to patch everything)\n"
|
||||
"Only patch BSSGP headers\n"
|
||||
"Patch BSSGP headers and LLC Attach Request messages\n"
|
||||
"Patch BSSGP headers and LLC Attach Request/Accept messages\n"
|
||||
"Patch BSSGP headers and LLC GMM messages\n"
|
||||
"Patch BSSGP headers, LLC GMM, and LLC GSM messages\n"
|
||||
"Patch BSSGP headers and all supported LLC messages\n"
|
||||
)
|
||||
{
|
||||
int val = get_string_value(patch_modes, argv[0]);
|
||||
OSMO_ASSERT(val >= 0);
|
||||
g_cfg->patch_mode = val;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy [stats]",
|
||||
SHOW_STR "Display information about the Gb proxy\n" "Show statistics\n")
|
||||
{
|
||||
|
@ -698,7 +663,6 @@ int gbproxy_vty_init(void)
|
|||
install_element(GBPROXY_NODE, &cfg_gbproxy_no_acquire_imsi_cmd);
|
||||
install_element(GBPROXY_NODE, &cfg_gbproxy_tlli_list_no_max_age_cmd);
|
||||
install_element(GBPROXY_NODE, &cfg_gbproxy_tlli_list_no_max_len_cmd);
|
||||
install_element(GBPROXY_NODE, &cfg_gbproxy_patch_mode_cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue