summaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-04 11:42:08 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-09 10:10:25 +0200
commit1abfdc218e044b764b385921be921aa05364bf47 (patch)
treeb3606eca5975f43ac23d402fc66de3096be34a37 /openbsc/src
parent7fb26c2943b46c9082d7615dc98095bf6bbe5905 (diff)
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
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/gprs/gb_proxy.c6
-rw-r--r--openbsc/src/gprs/gb_proxy_patch.c42
-rw-r--r--openbsc/src/gprs/gb_proxy_vty.c36
3 files changed, 6 insertions, 78 deletions
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index fbac298e3..f7afe947d 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -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),
diff --git a/openbsc/src/gprs/gb_proxy_patch.c b/openbsc/src/gprs/gb_proxy_patch.c
index 970f2f62c..be3ebd986 100644
--- a/openbsc/src/gprs/gb_proxy_patch.c
+++ b/openbsc/src/gprs/gb_proxy_patch.c
@@ -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
diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c
index 8bdc1accf..fd49b0179 100644
--- a/openbsc/src/gprs/gb_proxy_vty.c
+++ b/openbsc/src/gprs/gb_proxy_vty.c
@@ -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;
}